home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / mySQL / mysql-4.0.21-win / data1.cab / Documentation / Docs / manual.txt < prev    next >
Encoding:
Text File  |  2004-09-09  |  3.5 MB  |  90,234 lines

Text Truncated. Only the first 1MB is shown below. Download the file for the complete contents.
  1. START-INFO-DIR-ENTRY
  2. * mysql: (mysql).               MySQL documentation.
  3. END-INFO-DIR-ENTRY
  4.  
  5. Table of Contents
  6. *****************
  7.  
  8.  
  9. General Information
  10.   About This Manual
  11.     Conventions Used in This Manual
  12.   Overview of the MySQL Database Management System
  13.     History of MySQL
  14.     The Main Features of MySQL
  15.     MySQL Stability
  16.     How Big MySQL Tables Can Be
  17.     Year 2000 Compliance
  18.   Overview of MySQL AB
  19.     The Business Model and Services of MySQL AB
  20.       Support
  21.       Training and Certification
  22.       Consulting
  23.       Commercial Licenses
  24.       Partnering
  25.     Contact Information
  26.   MySQL Support and Licensing
  27.     Support Offered by MySQL AB
  28.     Copyrights and Licenses Used by MySQL
  29.     MySQL Licenses
  30.       Using the MySQL Software Under a Commercial License
  31.       Using the MySQL Software for Free Under GPL
  32.     MySQL AB Logos and Trademarks
  33.       The Original MySQL Logo
  34.       MySQL Logos That May Be Used Without Written Permission
  35.       When You Need Written Permission to Use MySQL Logos
  36.       MySQL AB Partnership Logos
  37.       Using the Word MySQL in Printed Text or Presentations
  38.       Using the Word MySQL in Company and Product Names
  39.   MySQL Development Roadmap
  40.     MySQL 4.0 in a Nutshell
  41.       Features Available in MySQL 4.0
  42.       The Embedded MySQL Server
  43.     MySQL 4.1 in a Nutshell
  44.       Features Available in MySQL 4.1
  45.       Stepwise Rollout
  46.       Ready for Immediate Development Use
  47.     MySQL 5.0: The Next Development Release
  48.   MySQL and the Future (the TODO)
  49.     New Features Planned for 4.1
  50.     New Features Planned for 5.0
  51.     New Features Planned for 5.1
  52.     New Features Planned for the Near Future
  53.     New Features Planned for the Mid-Term Future
  54.     New Features We Don't Plan to Implement
  55.   MySQL Information Sources
  56.     MySQL Mailing Lists
  57.       The MySQL Mailing Lists
  58.       Asking Questions or Reporting Bugs
  59.       How to Report Bugs or Problems
  60.       Guidelines for Answering Questions on the Mailing List
  61.     MySQL Community Support on IRC (Internet Relay Chat)
  62.   MySQL Standards Compliance
  63.     What Standards MySQL Follows
  64.     Selecting SQL Modes
  65.     Running MySQL in ANSI Mode
  66.     MySQL Extensions to Standard SQL
  67.     MySQL Differences from Standard SQL
  68.       Subqueries
  69.       `SELECT INTO TABLE'
  70.       Transactions and Atomic Operations
  71.       Stored Procedures and Triggers
  72.       Foreign Keys
  73.       Views
  74.       `--' as the Start of a Comment
  75.     How MySQL Deals with Constraints
  76.       Constraint `PRIMARY KEY' / `UNIQUE'
  77.       Constraint `NOT NULL' and `DEFAULT' Values
  78.       Constraint `ENUM' and `SET'
  79.     Known Errors and Design Deficiencies in MySQL
  80.       Errors in 3.23 Fixed in a Later MySQL Version
  81.       Errors in 4.0 Fixed in a Later MySQL Version
  82.       Open Bugs and Design Deficiencies in MySQL
  83.  
  84. Installing MySQL
  85.   General Installation Issues
  86.     Operating Systems Supported by MySQL
  87.     Choosing Which MySQL Distribution to Install
  88.       Choosing Which Version of MySQL to Install
  89.       Choosing a Distribution Format
  90.       How and When Updates Are Released
  91.       Release Philosophy--No Known Bugs in Releases
  92.       MySQL Binaries Compiled by MySQL AB
  93.     How to Get MySQL
  94.     Verifying Package Integrity Using MD5 Checksums or `GnuPG'
  95.       Verifying the MD5 Checksum
  96.       Signature Checking Using `GnuPG'
  97.       Signature Checking Using `RPM'
  98.     Installation Layouts
  99.   Standard MySQL Installation Using a Binary Distribution
  100.     Installing MySQL on Windows
  101.       Windows System Requirements
  102.       Installing a Windows Binary Distribution
  103.       Preparing the Windows MySQL Environment
  104.       Selecting a Windows Server
  105.       Starting the Server for the First Time
  106.       Starting MySQL from the Windows Command Line
  107.       Starting MySQL as a Windows Service
  108.       Troubleshooting a MySQL Installation Under Windows
  109.       Running MySQL Client Programs on Windows
  110.       MySQL on Windows Compared to MySQL on Unix
  111.     Installing MySQL on Linux
  112.     Installing MySQL on Mac OS X
  113.     Installing MySQL on NetWare
  114.     Installing MySQL on Other Unix-Like Systems
  115.   MySQL Installation Using a Source Distribution
  116.     Source Installation Overview
  117.     Typical `configure' Options
  118.     Installing from the Development Source Tree
  119.     Dealing with Problems Compiling MySQL
  120.     MIT-pthreads Notes
  121.     Installing MySQL from Source on Windows
  122.       Building MySQL Using VC++
  123.       Creating a Windows Source Package from the Latest Development Source
  124.     Compiling MySQL Clients on Windows
  125.   Post-Installation Setup and Testing
  126.     Windows Post-Installation Procedures
  127.     Unix Post-Installation Procedures
  128.       Problems Running `mysql_install_db'
  129.       Starting and Stopping MySQL Automatically
  130.       Starting and Troubleshooting the MySQL Server
  131.     Securing the Initial MySQL Accounts
  132.   Upgrading/Downgrading MySQL
  133.     Upgrading from Version 4.1 to 5.0
  134.     Upgrading from Version 4.0 to 4.1
  135.     Upgrading from Version 3.23 to 4.0
  136.     Upgrading from Version 3.22 to 3.23
  137.     Upgrading from Version 3.21 to 3.22
  138.     Upgrading from Version 3.20 to 3.21
  139.     Upgrading MySQL Under Windows
  140.     Upgrading the Grant Tables
  141.     Copying MySQL Databases to Another Machine
  142.   Operating System-Specific Notes
  143.     Linux Notes
  144.       Linux Operating System Notes
  145.       Linux Binary Distribution Notes
  146.       Linux Source Distribution Notes
  147.       Linux Post-Installation Notes
  148.       Linux x86 Notes
  149.       Linux SPARC Notes
  150.       Linux Alpha Notes
  151.       Linux PowerPC Notes
  152.       Linux MIPS Notes
  153.       Linux IA-64 Notes
  154.     Mac OS X Notes
  155.       Mac OS X 10.x (Darwin)
  156.       Mac OS X Server 1.2 (Rhapsody)
  157.     Solaris Notes
  158.       Solaris 2.7/2.8 Notes
  159.       Solaris x86 Notes
  160.     BSD Notes
  161.       FreeBSD Notes
  162.       NetBSD Notes
  163.       OpenBSD 2.5 Notes
  164.       OpenBSD 2.8 Notes
  165.       BSD/OS Version 2.x Notes
  166.       BSD/OS Version 3.x Notes
  167.       BSD/OS Version 4.x Notes
  168.     Other Unix Notes
  169.       HP-UX Version 10.20 Notes
  170.       HP-UX Version 11.x Notes
  171.       IBM-AIX notes
  172.       SunOS 4 Notes
  173.       Alpha-DEC-UNIX Notes (Tru64)
  174.       Alpha-DEC-OSF/1 Notes
  175.       SGI Irix Notes
  176.       SCO Notes
  177.       SCO UnixWare Version 7.1.x Notes
  178.     OS/2 Notes
  179.     BeOS Notes
  180.   Perl Installation Notes
  181.     Installing Perl on Unix
  182.     Installing ActiveState Perl on Windows
  183.     Problems Using the Perl `DBI'/`DBD' Interface
  184.  
  185. MySQL Tutorial
  186.   Connecting to and Disconnecting from the Server
  187.   Entering Queries
  188.   Creating and Using a Database
  189.     Creating and Selecting a Database
  190.     Creating a Table
  191.     Loading Data into a Table
  192.     Retrieving Information from a Table
  193.       Selecting All Data
  194.       Selecting Particular Rows
  195.       Selecting Particular Columns
  196.       Sorting Rows
  197.       Date Calculations
  198.       Working with `NULL' Values
  199.       Pattern Matching
  200.       Counting Rows
  201.       Using More Than one Table
  202.   Getting Information About Databases and Tables
  203.   Using `mysql' in Batch Mode
  204.   Examples of Common Queries
  205.     The Maximum Value for a Column
  206.     The Row Holding the Maximum of a Certain Column
  207.     Maximum of Column per Group
  208.     The Rows Holding the Group-wise Maximum of a Certain Field
  209.     Using User Variables
  210.     Using Foreign Keys
  211.     Searching on Two Keys
  212.     Calculating Visits Per Day
  213.     Using `AUTO_INCREMENT'
  214.   Queries from the Twin Project
  215.     Find All Non-distributed Twins
  216.     Show a Table of Twin Pair Status
  217.   Using MySQL with Apache
  218.  
  219. Using MySQL Programs
  220.   Overview of MySQL Programs
  221.   Invoking MySQL Programs
  222.   Specifying Program Options
  223.     Using Options on the Command Line
  224.     Using Option Files
  225.     Using Environment Variables to Specify Options
  226.     Using Options to Set Program Variables
  227.  
  228. Database Administration
  229.   The MySQL Server and Server Startup Scripts
  230.     Overview of the Server-Side Scripts and Utilities
  231.     The `mysqld-max' Extended MySQL Server
  232.     The `mysqld_safe' Server Startup Script
  233.     The `mysql.server' Server Startup Script
  234.     The `mysqld_multi' Program for Managing Multiple MySQL Servers
  235.   Configuring the MySQL Server
  236.     `mysqld' Command-Line Options
  237.     The Server SQL Mode
  238.     Server System Variables
  239.       Dynamic System Variables
  240.     Server Status Variables
  241.   The MySQL Server Shutdown Process
  242.   General Security Issues
  243.     General Security Guidelines
  244.     Making MySQL Secure Against Attackers
  245.     Startup Options for `mysqld' Concerning Security
  246.     Security Issues with `LOAD DATA LOCAL'
  247.   The MySQL Access Privilege System
  248.     What the Privilege System Does
  249.     How the Privilege System Works
  250.     Privileges Provided by MySQL
  251.     Connecting to the MySQL Server
  252.     Access Control, Stage 1: Connection Verification
  253.     Access Control, Stage 2: Request Verification
  254.     When Privilege Changes Take Effect
  255.     Causes of `Access denied' Errors
  256.     Password Hashing in MySQL 4.1
  257.       Implications of Password Hashing Changes for Application Programs
  258.       Password Hashing in MySQL 4.1.0
  259.   MySQL User Account Management
  260.     MySQL Usernames and Passwords
  261.     Adding New User Accounts to MySQL
  262.     Removing User Accounts from MySQL
  263.     Limiting Account Resources
  264.     Assigning Account Passwords
  265.     Keeping Your Password Secure
  266.     Using Secure Connections
  267.       Basic SSL Concepts
  268.       Requirements
  269.       Setting Up SSL Certificates for MySQL
  270.       SSL `GRANT' Options
  271.       SSL Command-Line Options
  272.       Connecting to MySQL Remotely from Windows with SSH
  273.   Disaster Prevention and Recovery
  274.     Database Backups
  275.     Table Maintenance and Crash Recovery
  276.       `myisamchk' Invocation Syntax
  277.       General Options for `myisamchk'
  278.       Check Options for `myisamchk'
  279.       Repair Options for `myisamchk'
  280.       Other Options for `myisamchk'
  281.       `myisamchk' Memory Usage
  282.       Using `myisamchk' for Crash Recovery
  283.       How to Check `MyISAM' Tables for Errors
  284.       How to Repair Tables
  285.       Table Optimization
  286.     Setting Up a Table Maintenance Schedule
  287.     Getting Information About a Table
  288.   MySQL Localization and International Usage
  289.     The Character Set Used for Data and Sorting
  290.       Using the German Character Set
  291.     Setting the Error Message Language
  292.     Adding a New Character Set
  293.     The Character Definition Arrays
  294.     String Collating Support
  295.     Multi-Byte Character Support
  296.     Problems With Character Sets
  297.     MySQL Server Time Zone Support
  298.   The MySQL Log Files
  299.     The Error Log
  300.     The General Query Log
  301.     The Update Log
  302.     The Binary Log
  303.     The Slow Query Log
  304.     Log File Maintenance
  305.   Running Multiple MySQL Servers on the Same Machine
  306.     Running Multiple Servers on Windows
  307.       Starting Multiple Windows Servers at the Command Line
  308.       Starting Multiple Windows Servers as Services
  309.     Running Multiple Servers on Unix
  310.     Using Client Programs in a Multiple-Server Environment
  311.   The MySQL Query Cache
  312.     How the Query Cache Operates
  313.     Query Cache `SELECT' Options
  314.     Query Cache Configuration
  315.     Query Cache Status and Maintenance
  316.  
  317. Replication in MySQL
  318.   Introduction to Replication
  319.   Replication Implementation Overview
  320.   Replication Implementation Details
  321.     Replication Master Thread States
  322.     Replication Slave I/O Thread States
  323.     Replication Slave SQL Thread States
  324.     Replication Relay and Status Files
  325.   How to Set Up Replication
  326.   Replication Compatibility Between MySQL Versions
  327.   Upgrading a Replication Setup
  328.     Upgrading Replication to 4.0 or 4.1
  329.     Upgrading Replication to 5.0
  330.   Replication Features and Known Problems
  331.   Replication Startup Options
  332.   Replication FAQ
  333.   Troubleshooting Replication
  334.   Reporting Replication Bugs
  335.  
  336. MySQL Optimization
  337.   Optimization Overview
  338.     MySQL Design Limitations and Tradeoffs
  339.     Designing Applications for Portability
  340.     What We Have Used MySQL For
  341.     The MySQL Benchmark Suite
  342.     Using Your Own Benchmarks
  343.   Optimizing `SELECT' Statements and Other Queries
  344.     `EXPLAIN' Syntax (Get Information About a `SELECT')
  345.     Estimating Query Performance
  346.     Speed of `SELECT' Queries
  347.     How MySQL Optimizes `WHERE' Clauses
  348.     How MySQL Optimizes `OR' Clauses
  349.     How MySQL Optimizes `IS NULL'
  350.     How MySQL Optimizes `DISTINCT'
  351.     How MySQL Optimizes `LEFT JOIN' and `RIGHT JOIN'
  352.     How MySQL Optimizes `ORDER BY'
  353.     How MySQL Optimizes `LIMIT'
  354.     How to Avoid Table Scans
  355.     Speed of `INSERT' Statements
  356.     Speed of `UPDATE' Statements
  357.     Speed of `DELETE' Statements
  358.     Other Optimization Tips
  359.   Locking Issues
  360.     Locking Methods
  361.     Table Locking Issues
  362.   Optimizing Database Structure
  363.     Design Choices
  364.     Make Your Data as Small as Possible
  365.     Column Indexes
  366.     Multiple-Column Indexes
  367.     How MySQL Uses Indexes
  368.     The `MyISAM' Key Cache
  369.       Shared Key Cache Access
  370.       Multiple Key Caches
  371.       Midpoint Insertion Strategy
  372.       Index Preloading
  373.       Key Cache Block Size
  374.       Restructuring a Key Cache
  375.     How MySQL Counts Open Tables
  376.     How MySQL Opens and Closes Tables
  377.     Drawbacks to Creating Many Tables in the Same Database
  378.   Optimizing the MySQL Server
  379.     System Factors and Startup Parameter Tuning
  380.     Tuning Server Parameters
  381.     Controlling Query Optimizer Performance
  382.     How Compiling and Linking Affects the Speed of MySQL
  383.     How MySQL Uses Memory
  384.     How MySQL Uses DNS
  385.   Disk Issues
  386.     Using Symbolic Links
  387.       Using Symbolic Links for Databases on Unix
  388.       Using Symbolic Links for Tables on Unix
  389.       Using Symbolic Links for Databases on Windows
  390.  
  391. MySQL Client and Utility Programs
  392.   Overview of the Client-Side Scripts and Utilities
  393.   `myisampack', the MySQL Compressed Read-only Table Generator
  394.   `mysql', the Command-Line Tool
  395.     `mysql' Commands
  396.     Executing SQL Statements from a Text File
  397.     `mysql' Tips
  398.       Displaying Query Results Vertically
  399.       Using the `--safe-updates' Option
  400.       Disabling `mysql' Auto-Reconnect
  401.   `mysqladmin', Administering a MySQL Server
  402.   The `mysqlbinlog' Binary Log Utility
  403.   `mysqlcc', the MySQL Control Center
  404.   The `mysqlcheck' Table Maintenance and Repair Program
  405.   The `mysqldump' Database Backup Program
  406.   The `mysqlhotcopy' Database Backup Program
  407.   The `mysqlimport' Data Import Program
  408.   `mysqlshow', Showing Databases, Tables, and Columns
  409.   `perror', Explaining Error Codes
  410.   The `replace' String-Replacement Utility
  411.  
  412. MySQL Language Reference
  413.  
  414. Language Structure
  415.   Literal Values
  416.     Strings
  417.     Numbers
  418.     Hexadecimal Values
  419.     Boolean Values
  420.     `NULL' Values
  421.   Database, Table, Index, Column, and Alias Names
  422.     Identifier Qualifiers
  423.     Identifier Case Sensitivity
  424.   User Variables
  425.   System Variables
  426.     Structured System Variables
  427.   Comment Syntax
  428.   Treatment of Reserved Words in MySQL
  429.  
  430. Character Set Support
  431.   Character Sets and Collations in General
  432.   Character Sets and Collations in MySQL
  433.   Determining the Default Character Set and Collation
  434.     Server Character Set and Collation
  435.     Database Character Set and Collation
  436.     Table Character Set and Collation
  437.     Column Character Set and Collation
  438.     Examples of Character Set and Collation Assignment
  439.     Connection Character Sets and Collations
  440.     Character String Literal Character Set and Collation
  441.     Using `COLLATE' in SQL Statements
  442.     `COLLATE' Clause Precedence
  443.     `BINARY' Operator
  444.     Some Special Cases Where the Collation Determination Is Tricky
  445.     Collations Must Be for the Right Character Set
  446.     An Example of the Effect of Collation
  447.   Operations Affected by Character Set Support
  448.     Result Strings
  449.     `CONVERT()'
  450.     `CAST()'
  451.     `SHOW' Statements
  452.   Unicode Support
  453.   UTF8 for Metadata
  454.   Compatibility with Other DBMSs
  455.   New Character Set Configuration File Format
  456.   National Character Set
  457.   Upgrading Character Sets from MySQL 4.0
  458.     4.0 Character Sets and Corresponding 4.1 Character Set/Collation Pairs
  459.     Converting 4.0 Character Columns to 4.1 Format
  460.   Character Sets and Collations That MySQL Supports
  461.     Unicode Character Sets
  462.     West European Character Sets
  463.     Central European Character Sets
  464.     South European and Middle East Character Sets
  465.     Baltic Character Sets
  466.     Cyrillic Character Sets
  467.     Asian Character Sets
  468.  
  469. Column Types
  470.   Column Type Overview
  471.     Overview of Numeric Types
  472.     Overview of Date and Time Types
  473.     Overview of String Types
  474.   Numeric Types
  475.   Date and Time Types
  476.     The `DATETIME', `DATE', and `TIMESTAMP' Types
  477.       `TIMESTAMP' Properties Prior to MySQL 4.1
  478.       `TIMESTAMP' Properties as of MySQL 4.1
  479.     The `TIME' Type
  480.     The `YEAR' Type
  481.     Y2K Issues and Date Types
  482.   String Types
  483.     The `CHAR' and `VARCHAR' Types
  484.     The `BLOB' and `TEXT' Types
  485.     The `ENUM' Type
  486.     The `SET' Type
  487.   Column Type Storage Requirements
  488.   Choosing the Right Type for a Column
  489.   Using Column Types from Other Database Engines
  490.  
  491. Functions and Operators
  492.   Operators
  493.     Operator Precedence
  494.     Parentheses
  495.     Comparison Functions and Operators
  496.     Logical Operators
  497.   Control Flow Functions
  498.   String Functions
  499.     String Comparison Functions
  500.   Numeric Functions
  501.     Arithmetic Operators
  502.     Mathematical Functions
  503.   Date and Time Functions
  504.   Full-Text Search Functions
  505.     Boolean Full-Text Searches
  506.     Full-Text Searches with Query Expansion
  507.     Full-Text Restrictions
  508.     Fine-Tuning MySQL Full-Text Search
  509.     Full-Text Search TODO
  510.   Cast Functions and Operators
  511.   Other Functions
  512.     Bit Functions
  513.     Encryption Functions
  514.     Information Functions
  515.     Miscellaneous Functions
  516.   Functions and Modifiers for Use with `GROUP BY' Clauses
  517.     `GROUP BY' (Aggregate) Functions
  518.     `GROUP BY' Modifiers
  519.     `GROUP BY' with Hidden Fields
  520.  
  521. SQL Statement Syntax
  522.   Data Manipulation Statements
  523.     `DELETE' Syntax
  524.     `DO' Syntax
  525.     `HANDLER' Syntax
  526.     `INSERT' Syntax
  527.       `INSERT ... SELECT' Syntax
  528.       `INSERT DELAYED' Syntax
  529.     `LOAD DATA INFILE' Syntax
  530.     `REPLACE' Syntax
  531.     `SELECT' Syntax
  532.       `JOIN' Syntax
  533.       `UNION' Syntax
  534.     Subquery Syntax
  535.       The Subquery as Scalar Operand
  536.       Comparisons Using Subqueries
  537.       Subqueries with `ANY', `IN', and `SOME'
  538.       Subqueries with `ALL'
  539.       Correlated Subqueries
  540.       `EXISTS' and `NOT EXISTS'
  541.       Row Subqueries
  542.       Subqueries in the `FROM' clause
  543.       Subquery Errors
  544.       Optimizing Subqueries
  545.       Rewriting Subqueries as Joins for Earlier MySQL Versions
  546.     `TRUNCATE' Syntax
  547.     `UPDATE' Syntax
  548.   Data Definition Statements
  549.     `ALTER DATABASE' Syntax
  550.     `ALTER TABLE' Syntax
  551.     `ALTER VIEW' Syntax
  552.     `CREATE DATABASE' Syntax
  553.     `CREATE INDEX' Syntax
  554.     `CREATE TABLE' Syntax
  555.       Silent Column Specification Changes
  556.     `CREATE VIEW' Syntax
  557.     `DROP DATABASE' Syntax
  558.     `DROP INDEX' Syntax
  559.     `DROP TABLE' Syntax
  560.     `DROP VIEW' Syntax
  561.     `RENAME TABLE' Syntax
  562.   MySQL Utility Statements
  563.     `DESCRIBE' Syntax (Get Information About Columns)
  564.     `USE' Syntax
  565.   MySQL Transactional and Locking Statements
  566.     `START TRANSACTION', `COMMIT', and `ROLLBACK' Syntax
  567.     Statements That Cannot Be Rolled Back
  568.     Statements That Cause an Implicit Commit
  569.     `SAVEPOINT' and `ROLLBACK TO SAVEPOINT' Syntax
  570.     `LOCK TABLES' and `UNLOCK TABLES' Syntax
  571.     `SET TRANSACTION' Syntax
  572.   Database Administration Statements
  573.     Account Management Statements
  574.       `DROP USER' Syntax
  575.       `GRANT' and `REVOKE' Syntax
  576.       `SET PASSWORD' Syntax
  577.     Table Maintenance Statements
  578.       `ANALYZE TABLE' Syntax
  579.       `BACKUP TABLE' Syntax
  580.       `CHECK TABLE' Syntax
  581.       `CHECKSUM TABLE' Syntax
  582.       `OPTIMIZE TABLE' Syntax
  583.       `REPAIR TABLE' Syntax
  584.       `RESTORE TABLE' Syntax
  585.     `SET' and `SHOW' Syntax
  586.       `SET' Syntax
  587.       `SHOW CHARACTER SET' Syntax
  588.       `SHOW COLLATION' Syntax
  589.       `SHOW COLUMNS' Syntax
  590.       `SHOW CREATE DATABASE' Syntax
  591.       `SHOW CREATE TABLE' Syntax
  592.       `SHOW CREATE VIEW' Syntax
  593.       `SHOW DATABASES' Syntax
  594.       `SHOW ENGINES' Syntax
  595.       `SHOW ERRORS' Syntax
  596.       `SHOW GRANTS' Syntax
  597.       `SHOW INDEX' Syntax
  598.       `SHOW INNODB STATUS' Syntax
  599.       `SHOW LOGS' Syntax
  600.       `SHOW PRIVILEGES' Syntax
  601.       `SHOW PROCESSLIST' Syntax
  602.       `SHOW STATUS' Syntax
  603.       `SHOW TABLE STATUS' Syntax
  604.       `SHOW TABLES' Syntax
  605.       `SHOW VARIABLES' Syntax
  606.       `SHOW WARNINGS' Syntax
  607.     Other Administrative Statements
  608.       `CACHE INDEX' Syntax
  609.       `FLUSH' Syntax
  610.       `KILL' Syntax
  611.       `LOAD INDEX INTO CACHE' Syntax
  612.       `RESET' Syntax
  613.   Replication Statements
  614.     SQL Statements for Controlling Master Servers
  615.       `PURGE MASTER LOGS' Syntax
  616.       `RESET MASTER' Syntax
  617.       `SET SQL_LOG_BIN' Syntax
  618.       `SHOW BINLOG EVENTS' Syntax
  619.       `SHOW MASTER LOGS' Syntax
  620.       `SHOW MASTER STATUS' Syntax
  621.       `SHOW SLAVE HOSTS' Syntax
  622.     SQL Statements for Controlling Slave Servers
  623.       `CHANGE MASTER TO' Syntax
  624.       `LOAD DATA FROM MASTER' Syntax
  625.       `LOAD TABLE TBL_NAME FROM MASTER' Syntax
  626.       `MASTER_POS_WAIT()' Syntax
  627.       `RESET SLAVE' Syntax
  628.       `SET GLOBAL SQL_SLAVE_SKIP_COUNTER' Syntax
  629.       `SHOW SLAVE STATUS' Syntax
  630.       `START SLAVE' Syntax
  631.       `STOP SLAVE' Syntax
  632.   SQL Syntax for Prepared Statements
  633.  
  634. MySQL Storage Engines and Table Types
  635.   The `MyISAM' Storage Engine
  636.     `MyISAM' Startup Options
  637.     Space Needed for Keys
  638.     `MyISAM' Table Storage Formats
  639.       Static (Fixed-Length) Table Characteristics
  640.       Dynamic Table Characteristics
  641.       Compressed Table Characteristics
  642.     `MyISAM' Table Problems
  643.       Corrupted `MyISAM' Tables
  644.       Problems from Tables Not Being Closed Properly
  645.   The `MERGE' Storage Engine
  646.     `MERGE' Table Problems
  647.   The `MEMORY' (`HEAP') Storage Engine
  648.   The `BDB' (`BerkeleyDB') Storage Engine
  649.     Operating Systems Supported by `BDB'
  650.     Installing `BDB'
  651.     `BDB' Startup Options
  652.     Characteristics of `BDB' Tables
  653.     Things We Need to Fix for `BDB'
  654.     Restrictions on `BDB' Tables
  655.     Errors That May Occur When Using `BDB' Tables
  656.   The `ISAM' Storage Engine
  657.  
  658. The `InnoDB' Storage Engine
  659.   `InnoDB' Overview
  660.   `InnoDB' Contact Information
  661.   `InnoDB' in MySQL 3.23
  662.   `InnoDB' Configuration
  663.   `InnoDB' Startup Options
  664.   Creating the `InnoDB' Tablespace
  665.     Dealing with `InnoDB' Initialization Problems
  666.   Creating `InnoDB' Tables
  667.     How to Use Transactions in `InnoDB' with Different APIs
  668.     Converting `MyISAM' Tables to `InnoDB'
  669.     How an `AUTO_INCREMENT' Column Works in `InnoDB'
  670.     `FOREIGN KEY' Constraints
  671.     `InnoDB' and MySQL Replication
  672.     Using Per-Table Tablespaces
  673.   Adding and Removing `InnoDB' Data and Log Files
  674.   Backing Up and Recovering an `InnoDB' Database
  675.     Forcing Recovery
  676.     Checkpoints
  677.   Moving an `InnoDB' Database to Another Machine
  678.   `InnoDB' Transaction Model and Locking
  679.     `InnoDB' and `AUTOCOMMIT'
  680.     `InnoDB' and `TRANSACTION ISOLATION LEVEL'
  681.     Consistent Non-Locking Read
  682.     Locking Reads `SELECT ... FOR UPDATE' and `SELECT ... LOCK IN SHARE MODE'
  683.     Next-Key Locking: Avoiding the Phantom Problem
  684.     An Example of How the Consistent Read Works in `InnoDB'
  685.     Locks Set by Different SQL Statements in `InnoDB'
  686.     When Does MySQL Implicitly Commit or Roll Back a Transaction?
  687.     Deadlock Detection and Rollback
  688.     How to Cope with Deadlocks
  689.   `InnoDB' Performance Tuning Tips
  690.     `SHOW INNODB STATUS' and the `InnoDB' Monitors
  691.   Implementation of Multi-Versioning
  692.   Table and Index Structures
  693.     Physical Structure of an Index
  694.     Insert Buffering
  695.     Adaptive Hash Indexes
  696.     Physical Record Structure
  697.   File Space Management and Disk I/O
  698.     Disk I/O
  699.     Using Raw Devices for the Tablespace
  700.     File Space Management
  701.     Defragmenting a Table
  702.   Error Handling
  703.     `InnoDB' Error Codes
  704.     Operating System Error Codes
  705.   Restrictions on `InnoDB' Tables
  706.   `InnoDB' Troubleshooting
  707.     Troubleshooting `InnoDB' Data Dictionary Operations
  708.  
  709. MySQL Cluster
  710.   MySQL Cluster Overview
  711.   Basic MySQL Cluster Concepts
  712.   MySQL Cluster Configuration
  713.     Building from Source Code
  714.     Installing the Software
  715.     Quick Test Setup of MySQL Cluster
  716.     Configuration File
  717.       An example configuration in a MySQL Cluster
  718.       Defining the computers in a MySQL Cluster
  719.       Defining the management server in a MySQL Cluster
  720.       Defining the storage nodes in a MySQL Cluster
  721.       Defining the MySQL Servers in a MySQL Cluster
  722.       Defining TCP/IP connections in a MySQL Cluster
  723.       Defining shared-memory connections in a MySQL Cluster
  724.   Process Management in MySQL Cluster
  725.     MySQL Server Process Usage for MySQL Cluster
  726.     `ndbd', the Storage Engine Node Process
  727.     `ndb_mgmd', the Management Server Process
  728.     `ndb_mgm', the Management Client Process
  729.     Command Options for MySQL Cluster Processes
  730.       MySQL Cluster-Related Command Options for `mysqld'
  731.       Command Options for `ndbd'
  732.       Command Options for `ndb_mgmd'
  733.       Command Options for `ndb_mgm'
  734.   Management of MySQL Cluster
  735.  
  736. Introduction to MaxDB
  737.   History of MaxDB
  738.   Licensing and Support
  739.   MaxDB-Related Links
  740.   Basic Concepts of MaxDB
  741.   Feature Differences Between MaxDB and MySQL
  742.   Interoperability Features Between MaxDB and MySQL
  743.   Reserved Words in MaxDB
  744.  
  745. Spatial Extensions in MySQL
  746.   Introduction
  747.   The OpenGIS Geometry Model
  748.     The Geometry Class Hierarchy
  749.     Class `Geometry'
  750.     Class `Point'
  751.     Class `Curve'
  752.     Class `LineString'
  753.     Class `Surface'
  754.     Class `Polygon'
  755.     Class `GeometryCollection'
  756.     Class `MultiPoint'
  757.     Class `MultiCurve'
  758.     Class `MultiLineString'
  759.     Class `MultiSurface'
  760.     Class `MultiPolygon'
  761.   Supported Spatial Data Formats
  762.     Well-Known Text (WKT) Format
  763.     Well-Known Binary (WKB) Format
  764.   Creating a Spatially Enabled MySQL Database
  765.     MySQL Spatial Data Types
  766.     Creating Spatial Values
  767.       Creating Geometry Values Using WKT Functions
  768.       Creating Geometry Values Using WKB Functions
  769.       Creating Geometry Values Using MySQL-Specific Functions
  770.     Creating Spatial Columns
  771.     Populating Spatial Columns
  772.     Fetching Spatial Data
  773.       Fetching Spatial Data in Internal Format
  774.       Fetching Spatial Data in WKT Format
  775.       Fetching Spatial Data in WKB Format
  776.   Analyzing Spatial Information
  777.     Geometry Format Conversion Functions
  778.     `Geometry' Functions
  779.       General Geometry Functions
  780.       `Point' Functions
  781.       `LineString' Functions
  782.       `MultiLineString' Functions
  783.       `Polygon' Functions
  784.       `MultiPolygon' Functions
  785.       `GeometryCollection' Functions
  786.     Functions That Create New Geometries from Existing Ones
  787.       Geometry Functions That Produce New Geometries
  788.       Spatial Operators
  789.     Functions for Testing Spatial Relations Between Geometric Objects
  790.     Relations on Geometry Minimal Bounding Rectangles (MBRs)
  791.     Functions That Test Spatial Relationships Between Geometries
  792.   Optimizing Spatial Analysis
  793.     Creating Spatial Indexes
  794.     Using a Spatial Index
  795.   MySQL Conformance and Compatibility
  796.     GIS Features That Are Not Yet Implemented
  797.  
  798. Stored Procedures and Functions
  799.   Stored Procedure Syntax
  800.     Maintaining Stored Procedures
  801.       `CREATE PROCEDURE' and `CREATE FUNCTION'
  802.       `ALTER PROCEDURE' and `ALTER FUNCTION'
  803.       `DROP PROCEDURE' and `DROP FUNCTION'
  804.       `SHOW CREATE PROCEDURE' and `SHOW CREATE FUNCTION'
  805.     `SHOW PROCEDURE STATUS' and `SHOW FUNCTION STATUS'
  806.     `CALL' Statement
  807.     `BEGIN ... END' Compound Statement
  808.     `DECLARE' Statement
  809.     Variables in Stored Procedures
  810.       `DECLARE' Local Variables
  811.       Variable `SET' Statement
  812.       `SELECT ... INTO' Statement
  813.     Conditions and Handlers
  814.       `DECLARE' Conditions
  815.       `DECLARE' Handlers
  816.     Cursors
  817.       Declaring Cursors
  818.       Cursor `OPEN' Statement
  819.       Cursor `FETCH' Statement
  820.       Cursor `CLOSE' Statement
  821.     Flow Control Constructs
  822.       `IF' Statement
  823.       `CASE' Statement
  824.       `LOOP' Statement
  825.       `LEAVE' Statement
  826.       `ITERATE' Statement
  827.       `REPEAT' Statement
  828.       `WHILE' Statement
  829.  
  830. MySQL APIs
  831.   MySQL Program Development Utilities
  832.     `msql2mysql', Convert mSQL Programs for Use with MySQL
  833.     `mysql_config', Get compile options for compiling clients
  834.   MySQL C API
  835.     C API Data types
  836.     C API Function Overview
  837.     C API Function Descriptions
  838.       `mysql_affected_rows()'
  839.       `mysql_change_user()'
  840.       `mysql_character_set_name()'
  841.       `mysql_close()'
  842.       `mysql_connect()'
  843.       `mysql_create_db()'
  844.       `mysql_data_seek()'
  845.       `mysql_debug()'
  846.       `mysql_drop_db()'
  847.       `mysql_dump_debug_info()'
  848.       `mysql_eof()'
  849.       `mysql_errno()'
  850.       `mysql_error()'
  851.       `mysql_escape_string()'
  852.       `mysql_fetch_field()'
  853.       `mysql_fetch_fields()'
  854.       `mysql_fetch_field_direct()'
  855.       `mysql_fetch_lengths()'
  856.       `mysql_fetch_row()'
  857.       `mysql_field_count()'
  858.       `mysql_field_seek()'
  859.       `mysql_field_tell()'
  860.       `mysql_free_result()'
  861.       `mysql_get_client_info()'
  862.       `mysql_get_client_version()'
  863.       `mysql_get_host_info()'
  864.       `mysql_get_proto_info()'
  865.       `mysql_get_server_info()'
  866.       `mysql_get_server_version()'
  867.       `mysql_info()'
  868.       `mysql_init()'
  869.       `mysql_insert_id()'
  870.       `mysql_kill()'
  871.       `mysql_list_dbs()'
  872.       `mysql_list_fields()'
  873.       `mysql_list_processes()'
  874.       `mysql_list_tables()'
  875.       `mysql_num_fields()'
  876.       `mysql_num_rows()'
  877.       `mysql_options()'
  878.       `mysql_ping()'
  879.       `mysql_query()'
  880.       `mysql_real_connect()'
  881.       `mysql_real_escape_string()'
  882.       `mysql_real_query()'
  883.       `mysql_reload()'
  884.       `mysql_row_seek()'
  885.       `mysql_row_tell()'
  886.       `mysql_select_db()'
  887.       `mysql_set_server_option()'
  888.       `mysql_shutdown()'
  889.       `mysql_sqlstate()'
  890.       `mysql_ssl_set()'
  891.       `mysql_stat()'
  892.       `mysql_store_result()'
  893.       `mysql_thread_id()'
  894.       `mysql_use_result()'
  895.       `mysql_warning_count()'
  896.       `mysql_commit()'
  897.       `mysql_rollback()'
  898.       `mysql_autocommit()'
  899.       `mysql_more_results()'
  900.       `mysql_next_result()'
  901.     C API Prepared Statements
  902.     C API Prepared Statement Data types
  903.     C API Prepared Statement Function Overview
  904.     C API Prepared Statement Function Descriptions
  905.       `mysql_stmt_init()'
  906.       `mysql_stmt_bind_param()'
  907.       `mysql_stmt_bind_result()'
  908.       `mysql_stmt_execute()'
  909.       `mysql_stmt_fetch()'
  910.       `mysql_stmt_fetch_column()'
  911.       `mysql_stmt_result_metadata()'
  912.       `mysql_stmt_param_count()'
  913.       `mysql_stmt_param_metadata()'
  914.       `mysql_stmt_prepare()'
  915.       `mysql_stmt_send_long_data()'
  916.       `mysql_stmt_affected_rows()'
  917.       `mysql_stmt_insert_id()'
  918.       `mysql_stmt_close()'
  919.       `mysql_stmt_data_seek()'
  920.       `mysql_stmt_errno()'
  921.       `mysql_stmt_error()'
  922.       `mysql_stmt_free_result()'
  923.       `mysql_stmt_num_rows()'
  924.       `mysql_stmt_reset()'
  925.       `mysql_stmt_row_seek()'
  926.       `mysql_stmt_row_tell()'
  927.       `mysql_stmt_sqlstate()'
  928.       `mysql_stmt_store_result()'
  929.       `mysql_stmt_attr_set()'
  930.       `mysql_stmt_attr_get()'
  931.     C API Handling of Multiple Query Execution
  932.     C API Handling of Date and Time Values
  933.     C API Threaded Function Descriptions
  934.       `my_init()'
  935.       `mysql_thread_init()'
  936.       `mysql_thread_end()'
  937.       `mysql_thread_safe()'
  938.     C API Embedded Server Function Descriptions
  939.       `mysql_server_init()'
  940.       `mysql_server_end()'
  941.     Common questions and problems when using the C API
  942.       Why `mysql_store_result()' Sometimes Returns `NULL' After `mysql_query()' Returns Success
  943.       What Results You Can Get from a Query
  944.       How to Get the Unique ID for the Last Inserted Row
  945.       Problems Linking with the C API
  946.     Building Client Programs
  947.     How to Make a Threaded Client
  948.     libmysqld, the Embedded MySQL Server Library
  949.       Overview of the Embedded MySQL Server Library
  950.       Compiling Programs with `libmysqld'
  951.       Restrictions when using the Embedded MySQL Server
  952.       Using Option Files with the Embedded Server
  953.       Things left to do in Embedded Server (TODO)
  954.       A Simple Embedded Server Example
  955.       Licensing the Embedded Server
  956.   MySQL ODBC Support
  957.     How to Install MyODBC
  958.     How to Fill in the Various Fields in the ODBC Administrator Program
  959.     Connect parameters for MyODBC
  960.     How to Report Problems with MyODBC
  961.     Programs Known to Work with MyODBC
  962.     How to Get the Value of an `AUTO_INCREMENT' Column in ODBC
  963.     Reporting Problems with MyODBC
  964.   MySQL Java Connectivity (JDBC)
  965.   MySQL PHP API
  966.     Common Problems with MySQL and PHP
  967.   MySQL Perl API
  968.   MySQL C++ API
  969.     Borland C++
  970.   MySQL Python API
  971.   MySQL Tcl API
  972.   MySQL Eiffel Wrapper
  973.  
  974. Error Handling in MySQL
  975.  
  976. Extending MySQL
  977.   MySQL Internals
  978.     MySQL Threads
  979.     MySQL Test Suite
  980.       Running the MySQL Test Suite
  981.       Extending the MySQL Test Suite
  982.       Reporting Bugs in the MySQL Test Suite
  983.   Adding New Functions to MySQL
  984.     `CREATE FUNCTION/DROP FUNCTION' Syntax
  985.     Adding a New User-defined Function
  986.       UDF Calling Sequences for simple functions
  987.       UDF Calling Sequences for aggregate functions
  988.       Argument Processing
  989.       Return Values and Error Handling
  990.       Compiling and Installing User-defined Functions
  991.     Adding a New Native Function
  992.   Adding New Procedures to MySQL
  993.     Procedure Analyse
  994.     Writing a Procedure
  995.  
  996. Problems and Common Errors
  997.   How to Determine What Is Causing a Problem
  998.   Common Errors When Using MySQL Programs
  999.     `Access denied'
  1000.     `Can't connect to [local] MySQL server'
  1001.     `Client does not support authentication protocol'
  1002.     Password Fails When Entered Interactively
  1003.     `Host 'HOST_NAME' is blocked'
  1004.     `Too many connections'
  1005.     `Out of memory'
  1006.     `MySQL server has gone away'
  1007.     `Packet too large'
  1008.     Communication Errors and Aborted Connections
  1009.     `The table is full'
  1010.     `Can't create/write to file'
  1011.     `Commands out of sync'
  1012.     `Ignoring user'
  1013.     `Table 'TBL_NAME' doesn't exist'
  1014.     `Can't initialize character set'
  1015.     File Not Found
  1016.   Installation-Related Issues
  1017.     Problems Linking to the MySQL Client Library
  1018.     How to Run MySQL as a Normal User
  1019.     Problems with File Permissions
  1020.   Administration-Related Issues
  1021.     How to Reset the Root Password
  1022.     What to Do If MySQL Keeps Crashing
  1023.     How MySQL Handles a Full Disk
  1024.     Where MySQL Stores Temporary Files
  1025.     How to Protect or Change the MySQL Socket File `/tmp/mysql.sock'
  1026.     Time Zone Problems
  1027.   Query-Related Issues
  1028.     Case Sensitivity in Searches
  1029.     Problems Using `DATE' Columns
  1030.     Problems with `NULL' Values
  1031.     Problems with Column Aliases
  1032.     Rollback Failure for Non-Transactional Tables
  1033.     Deleting Rows from Related Tables
  1034.     Solving Problems with No Matching Rows
  1035.     Problems with Floating-Point Comparisons
  1036.   Optimizer-Related Issues
  1037.   Table Definition-Related Issues
  1038.     Problems with `ALTER TABLE'
  1039.     How to Change the Order of Columns in a Table
  1040.     `TEMPORARY TABLE' Problems
  1041.  
  1042. Credits
  1043.   Developers at MySQL AB
  1044.   Contributors to MySQL
  1045.   Documenters and translators
  1046.   Libraries used by and included with MySQL
  1047.   Packages that support MySQL
  1048.   Tools that were used to create MySQL
  1049.   Supporters of MySQL
  1050.  
  1051. MySQL Change History
  1052.   Changes in release 5.0.x (Development)
  1053.     Changes in release 5.0.2 (not released yet)
  1054.     Changes in release 5.0.1 (27 Jul 2004)
  1055.     Changes in release 5.0.0 (22 Dec 2003: Alpha)
  1056.   Changes in release 4.1.x (Beta)
  1057.     Changes in release 4.1.5 (not released yet)
  1058.     Changes in release 4.1.4 (26 Aug 2004: Gamma)
  1059.     Changes in release 4.1.3 (28 Jun 2004: Beta)
  1060.     Changes in release 4.1.2 (28 May 2004)
  1061.     Changes in release 4.1.1 (01 Dec 2003)
  1062.     Changes in release 4.1.0 (03 Apr 2003: Alpha)
  1063.   Changes in release 4.0.x (Production)
  1064.     Changes in release 4.0.22 (not released yet)
  1065.     Changes in release 4.0.21 (to be released soon)
  1066.     Changes in release 4.0.20 (17 May 2004)
  1067.     Changes in release 4.0.19 (04 May 2004)
  1068.     Changes in release 4.0.18 (12 Feb 2004)
  1069.     Changes in release 4.0.17 (14 Dec 2003)
  1070.     Changes in release 4.0.16 (17 Oct 2003)
  1071.     Changes in release 4.0.15 (03 Sep 2003)
  1072.     Changes in release 4.0.14 (18 Jul 2003)
  1073.     Changes in release 4.0.13 (16 May 2003)
  1074.     Changes in release 4.0.12 (15 Mar 2003: Production)
  1075.     Changes in release 4.0.11 (20 Feb 2003)
  1076.     Changes in release 4.0.10 (29 Jan 2003)
  1077.     Changes in release 4.0.9 (09 Jan 2003)
  1078.     Changes in release 4.0.8 (07 Jan 2003)
  1079.     Changes in release 4.0.7 (20 Dec 2002)
  1080.     Changes in release 4.0.6 (14 Dec 2002: Gamma)
  1081.     Changes in release 4.0.5 (13 Nov 2002)
  1082.     Changes in release 4.0.4 (29 Sep 2002)
  1083.     Changes in release 4.0.3 (26 Aug 2002: Beta)
  1084.     Changes in release 4.0.2 (01 Jul 2002)
  1085.     Changes in release 4.0.1 (23 Dec 2001)
  1086.     Changes in release 4.0.0 (Oct 2001: Alpha)
  1087.   Changes in release 3.23.x (Recent; still supported)
  1088.     Changes in release 3.23.59 (not released yet)
  1089.     Changes in release 3.23.58 (11 Sep 2003)
  1090.     Changes in release 3.23.57 (06 Jun 2003)
  1091.     Changes in release 3.23.56 (13 Mar 2003)
  1092.     Changes in release 3.23.55 (23 Jan 2003)
  1093.     Changes in release 3.23.54 (05 Dec 2002)
  1094.     Changes in release 3.23.53 (09 Oct 2002)
  1095.     Changes in release 3.23.52 (14 Aug 2002)
  1096.     Changes in release 3.23.51 (31 May 2002)
  1097.     Changes in release 3.23.50 (21 Apr 2002)
  1098.     Changes in release 3.23.49 (14 Feb 2002)
  1099.     Changes in release 3.23.48 (07 Feb 2002)
  1100.     Changes in release 3.23.47 (27 Dec 2001)
  1101.     Changes in release 3.23.46 (29 Nov 2001)
  1102.     Changes in release 3.23.45 (22 Nov 2001)
  1103.     Changes in release 3.23.44 (31 Oct 2001)
  1104.     Changes in release 3.23.43 (04 Oct 2001)
  1105.     Changes in release 3.23.42 (08 Sep 2001)
  1106.     Changes in release 3.23.41 (11 Aug 2001)
  1107.     Changes in release 3.23.40 (18 Jul 2001)
  1108.     Changes in release 3.23.39 (12 Jun 2001)
  1109.     Changes in release 3.23.38 (09 May 2001)
  1110.     Changes in release 3.23.37 (17 Apr 2001)
  1111.     Changes in release 3.23.36 (27 Mar 2001)
  1112.     Changes in release 3.23.35 (15 Mar 2001)
  1113.     Changes in release 3.23.34a (11 Mar 2001)
  1114.     Changes in release 3.23.34 (10 Mar 2001)
  1115.     Changes in release 3.23.33 (09 Feb 2001)
  1116.     Changes in release 3.23.32 (22 Jan 2001)
  1117.     Changes in release 3.23.31 (17 Jan 2001: Production)
  1118.     Changes in release 3.23.30 (04 Jan 2001)
  1119.     Changes in release 3.23.29 (16 Dec 2000)
  1120.     Changes in release 3.23.28 (22 Nov 2000: Gamma)
  1121.     Changes in release 3.23.27 (24 Oct 2000)
  1122.     Changes in release 3.23.26 (18 Oct 2000)
  1123.     Changes in release 3.23.25 (29 Sep 2000)
  1124.     Changes in release 3.23.24 (08 Sep 2000)
  1125.     Changes in release 3.23.23 (01 Sep 2000)
  1126.     Changes in release 3.23.22 (31 Jul 2000)
  1127.     Changes in release 3.23.21 (04 Jul 2000)
  1128.     Changes in release 3.23.20 (28 Jun 2000: Beta)
  1129.     Changes in release 3.23.19
  1130.     Changes in release 3.23.18 (11 Jun 2000)
  1131.     Changes in release 3.23.17 (07 Jun 2000)
  1132.     Changes in release 3.23.16 (16 May 2000)
  1133.     Changes in release 3.23.15 (08 May 2000)
  1134.     Changes in release 3.23.14 (09 Apr 2000)
  1135.     Changes in release 3.23.13 (14 Mar 2000)
  1136.     Changes in release 3.23.12 (07 Mar 2000)
  1137.     Changes in release 3.23.11 (16 Feb 2000)
  1138.     Changes in release 3.23.10 (30 Jan 2000)
  1139.     Changes in release 3.23.9 (29 Jan 2000)
  1140.     Changes in release 3.23.8 (02 Jan 2000)
  1141.     Changes in release 3.23.7 (10 Dec 1999)
  1142.     Changes in release 3.23.6 (15 Nov 1999)
  1143.     Changes in release 3.23.5 (20 Oct 1999)
  1144.     Changes in release 3.23.4 (28 Sep 1999)
  1145.     Changes in release 3.23.3 (13 Sep 1999)
  1146.     Changes in release 3.23.2 (09 Aug 1999)
  1147.     Changes in release 3.23.1 (08 Jul 1999)
  1148.     Changes in release 3.23.0 (05 Jul 1999: Alpha)
  1149.   Changes in release 3.22.x (Old; discontinued)
  1150.     Changes in release 3.22.35
  1151.     Changes in release 3.22.34
  1152.     Changes in release 3.22.33
  1153.     Changes in release 3.22.32 (14 Feb 2000)
  1154.     Changes in release 3.22.31
  1155.     Changes in release 3.22.30 (11 Jan 2000)
  1156.     Changes in release 3.22.29 (02 Jan 2000)
  1157.     Changes in release 3.22.28 (20 Oct 1999)
  1158.     Changes in release 3.22.27 (05 Oct 1999)
  1159.     Changes in release 3.22.26 (16 Sep 1999)
  1160.     Changes in release 3.22.25 (07 Jun 1999)
  1161.     Changes in release 3.22.24 (05 Jul 1999)
  1162.     Changes in release 3.22.23 (08 Jun 1999)
  1163.     Changes in release 3.22.22 (30 Apr 1999)
  1164.     Changes in release 3.22.21 (04 Apr 1999)
  1165.     Changes in release 3.22.20 (18 Mar 1999)
  1166.     Changes in release 3.22.19 (01 Mar 1999)
  1167.     Changes in release 3.22.18 (26 Feb 1999)
  1168.     Changes in release 3.22.17 (22 Feb 1999: Production)
  1169.     Changes in release 3.22.16 (05 Feb 1999)
  1170.     Changes in release 3.22.15 (27 Jan 1999)
  1171.     Changes in release 3.22.14 (01 Jan 1999: Gamma)
  1172.     Changes in release 3.22.13 (16 Dec 1998)
  1173.     Changes in release 3.22.12 (09 Dec 1998)
  1174.     Changes in release 3.22.11 (24 Nov 1998)
  1175.     Changes in release 3.22.10 (04 Nov 1998)
  1176.     Changes in release 3.22.9 (19 Oct 1998)
  1177.     Changes in release 3.22.8 (06 Oct 1998)
  1178.     Changes in release 3.22.7 (21 Sep 1998: Beta)
  1179.     Changes in release 3.22.6 (31 Aug 1998)
  1180.     Changes in release 3.22.5 (20 Aug 1998: Alpha)
  1181.     Changes in release 3.22.4 (06 Jul 1998: Beta)
  1182.     Changes in release 3.22.3 (30 Jun 1998)
  1183.     Changes in release 3.22.2
  1184.     Changes in release 3.22.1 (Jun 1998)
  1185.     Changes in release 3.22.0 (18 May 1998: Alpha)
  1186.   Changes in release 3.21.x
  1187.     Changes in release 3.21.33 (08 Jul 1998)
  1188.     Changes in release 3.21.32 (30 Jun 1998)
  1189.     Changes in release 3.21.31 (10 Jun 1998)
  1190.     Changes in release 3.21.30
  1191.     Changes in release 3.21.29
  1192.     Changes in release 3.21.28
  1193.     Changes in release 3.21.27
  1194.     Changes in release 3.21.26
  1195.     Changes in release 3.21.25
  1196.     Changes in release 3.21.24
  1197.     Changes in release 3.21.23
  1198.     Changes in release 3.21.22
  1199.     Changes in release 3.21.21a
  1200.     Changes in release 3.21.21
  1201.     Changes in release 3.21.20
  1202.     Changes in release 3.21.19
  1203.     Changes in release 3.21.18
  1204.     Changes in release 3.21.17
  1205.     Changes in release 3.21.16
  1206.     Changes in release 3.21.15
  1207.     Changes in release 3.21.14b
  1208.     Changes in release 3.21.14a
  1209.     Changes in release 3.21.13
  1210.     Changes in release 3.21.12
  1211.     Changes in release 3.21.11
  1212.     Changes in release 3.21.10
  1213.     Changes in release 3.21.9
  1214.     Changes in release 3.21.8
  1215.     Changes in release 3.21.7
  1216.     Changes in release 3.21.6
  1217.     Changes in release 3.21.5
  1218.     Changes in release 3.21.4
  1219.     Changes in release 3.21.3
  1220.     Changes in release 3.21.2
  1221.     Changes in release 3.21.0
  1222.   Changes in release 3.20.x
  1223.     Changes in release 3.20.18
  1224.     Changes in release 3.20.17
  1225.     Changes in release 3.20.16
  1226.     Changes in release 3.20.15
  1227.     Changes in release 3.20.14
  1228.     Changes in release 3.20.13
  1229.     Changes in release 3.20.11
  1230.     Changes in release 3.20.10
  1231.     Changes in release 3.20.9
  1232.     Changes in release 3.20.8
  1233.     Changes in release 3.20.7
  1234.     Changes in release 3.20.6
  1235.     Changes in release 3.20.3
  1236.     Changes in release 3.20.0
  1237.   Changes in release 3.19.x
  1238.     Changes in release 3.19.5
  1239.     Changes in release 3.19.4
  1240.     Changes in release 3.19.3
  1241.   `InnoDB' Change History
  1242.     MySQL/InnoDB-4.0.21, not released yet
  1243.     MySQL/InnoDB-4.1.4, August 31, 2004
  1244.     MySQL/InnoDB-4.1.3, June 28, 2004
  1245.     MySQL/InnoDB-4.1.2, May 30, 2004
  1246.     MySQL/InnoDB-4.0.20, May 18, 2004
  1247.     MySQL/InnoDB-4.0.19, May 4, 2004
  1248.     MySQL/InnoDB-4.0.18, February 13, 2004
  1249.     MySQL/InnoDB-5.0.0, December 24, 2003
  1250.     MySQL/InnoDB-4.0.17, December 17, 2003
  1251.     MySQL/InnoDB-4.1.1, December 4, 2003
  1252.     MySQL/InnoDB-4.0.16, October 22, 2003
  1253.     MySQL/InnoDB-3.23.58, September 15, 2003
  1254.     MySQL/InnoDB-4.0.15, September 10, 2003
  1255.     MySQL/InnoDB-4.0.14, July 22, 2003
  1256.     MySQL/InnoDB-3.23.57, June 20, 2003
  1257.     MySQL/InnoDB-4.0.13, May 20, 2003
  1258.     MySQL/InnoDB-4.1.0, April 3, 2003
  1259.     MySQL/InnoDB-3.23.56, March 17, 2003
  1260.     MySQL/InnoDB-4.0.12, March 18, 2003
  1261.     MySQL/InnoDB-4.0.11, February 25, 2003
  1262.     MySQL/InnoDB-4.0.10, February 4, 2003
  1263.     MySQL/InnoDB-3.23.55, January 24, 2003
  1264.     MySQL/InnoDB-4.0.9, January 14, 2003
  1265.     MySQL/InnoDB-4.0.8, January 7, 2003
  1266.     MySQL/InnoDB-4.0.7, December 26, 2002
  1267.     MySQL/InnoDB-4.0.6, December 19, 2002
  1268.     MySQL/InnoDB-3.23.54, December 12, 2002
  1269.     MySQL/InnoDB-4.0.5, November 18, 2002
  1270.     MySQL/InnoDB-3.23.53, October 9, 2002
  1271.     MySQL/InnoDB-4.0.4, October 2, 2002
  1272.     MySQL/InnoDB-4.0.3, August 28, 2002
  1273.     MySQL/InnoDB-3.23.52, August 16, 2002
  1274.     MySQL/InnoDB-4.0.2, July 10, 2002
  1275.     MySQL/InnoDB-3.23.51, June 12, 2002
  1276.     MySQL/InnoDB-3.23.50, April 23, 2002
  1277.     MySQL/InnoDB-3.23.49, February 17, 2002
  1278.     MySQL/InnoDB-3.23.48, February 9, 2002
  1279.     MySQL/InnoDB-3.23.47, December 28, 2001
  1280.     MySQL/InnoDB-4.0.1, December 23, 2001
  1281.     MySQL/InnoDB-3.23.46, November 30, 2001
  1282.     MySQL/InnoDB-3.23.45, November 23, 2001
  1283.     MySQL/InnoDB-3.23.44, November 2, 2001
  1284.     MySQL/InnoDB-3.23.43, October 4, 2001
  1285.     MySQL/InnoDB-3.23.42, September 9, 2001
  1286.     MySQL/InnoDB-3.23.41, August 13, 2001
  1287.     MySQL/InnoDB-3.23.40, July 16, 2001
  1288.     MySQL/InnoDB-3.23.39, June 13, 2001
  1289.     MySQL/InnoDB-3.23.38, May 12, 2001
  1290.  
  1291. Porting to Other Systems
  1292.   Debugging a MySQL Server
  1293.     Compiling MySQL for Debugging
  1294.     Creating Trace Files
  1295.     Debugging `mysqld' under `gdb'
  1296.     Using a Stack Trace
  1297.     Using Log Files to Find Cause of Errors in `mysqld'
  1298.     Making a Test Case If You Experience Table Corruption
  1299.   Debugging a MySQL Client
  1300.   The DBUG Package
  1301.   Comments about RTS Threads
  1302.   Differences Between Thread Packages
  1303.  
  1304. Environment Variables
  1305.  
  1306. MySQL Regular Expressions
  1307.  
  1308. GNU General Public License
  1309.  
  1310. MySQL FLOSS License Exception
  1311.  
  1312. SQL Command, Type, and Function Index
  1313.  
  1314. Concept Index
  1315.  
  1316.  
  1317. This is the Reference Manual for the MySQL Database System.  It
  1318. documents MySQL up to Version 4.0.21, but is also applicable for older
  1319. versions of the MySQL software (such as 3.23 or 4.0-production) because
  1320. functional changes are indicated with reference to a version number.
  1321.  
  1322. General Information
  1323. *******************
  1324.  
  1325. The MySQL (R) software delivers a very fast, multi-threaded,
  1326. multi-user, and robust SQL (Structured Query Language) database server.
  1327. MySQL Server is intended for mission-critical, heavy-load production
  1328. systems as well as for embedding into mass-deployed software.  MySQL is
  1329. a registered trademark of MySQL AB.
  1330.  
  1331. The MySQL software is Dual Licensed. Users can choose to use the MySQL
  1332. software as an Open Source/Free Software product under the terms of the
  1333. GNU General Public License (`http://www.fsf.org/licenses/') or can
  1334. purchase a standard commercial license from MySQL AB.  *Note Licensing
  1335. and Support::.
  1336.  
  1337. The MySQL Web site (`http://www.mysql.com/') provides the latest
  1338. information about the MySQL software.
  1339.  
  1340. The following list describes some sections of particular interest in
  1341. this manual:
  1342.  
  1343.    * For information about the company behind the MySQL Database Server,
  1344.      see *Note What is MySQL AB::.
  1345.  
  1346.    * For a discussion about the capabilities of the MySQL Database
  1347.      Server, see *Note Features::.
  1348.  
  1349.    * For installation instructions, see *Note Installing::.
  1350.  
  1351.    * For tips on porting the MySQL Database Software to new
  1352.      architectures or operating systems, see *Note Porting::.
  1353.  
  1354.    * For information about upgrading from a Version 4.0 release, see
  1355.      *Note Upgrading-from-4.0::.
  1356.  
  1357.    * For information about upgrading from a Version 3.23 release, see
  1358.      *Note Upgrading-from-3.23::.
  1359.  
  1360.    * For information about upgrading from a Version 3.22 release, see
  1361.      *Note Upgrading-from-3.22::.
  1362.  
  1363.    * For a tutorial introduction to the MySQL Database Server, see
  1364.      *Note Tutorial::.
  1365.  
  1366.    * For examples of SQL and benchmarking information, see the
  1367.      benchmarking directory (`sql-bench' in the distribution).
  1368.  
  1369.    * For a history of new features and bugfixes, see *Note News::.
  1370.  
  1371.    * For a list of currently known bugs and misfeatures, see *Note
  1372.      Bugs::.
  1373.  
  1374.    * For future plans, see *Note TODO::.
  1375.  
  1376.    * For a list of all the contributors to this project, see *Note
  1377.      Credits::.
  1378.  
  1379. *Important*:
  1380.  
  1381. Reports of errors (often called "bugs"), as well as questions and
  1382. comments, should be sent to the general MySQL mailing list.  *Note
  1383. Mailing-list::.  *Note Bug reports::.
  1384.  
  1385. The `mysqlbug' script should be used to generate bug reports on Unix.
  1386. (Windows distributions contain a file named `mysqlbug.txt' in the base
  1387. directory that can be used as a template for a bug report.)
  1388.  
  1389. For source distributions, the `mysqlbug' script can be found in the
  1390. `scripts' directory. For binary distributions, `mysqlbug' can be found
  1391. in the `bin' directory (`/usr/bin' for the `MySQL-server' RPM package).
  1392.  
  1393. If you have found a sensitive security bug in MySQL Server, please let
  1394. us know immediately by sending an email message to <security@mysql.com>.
  1395.  
  1396. About This Manual
  1397. =================
  1398.  
  1399. This is the Reference Manual for the MySQL Database System.  It
  1400. documents MySQL up to Version 4.0.21, but is also applicable for older
  1401. versions of the MySQL software (such as 3.23 or 4.0-production) because
  1402. functional changes are indicated with reference to a version number.
  1403.  
  1404. Because this manual serves as a reference, it does not provide general
  1405. instruction on SQL or relational database concepts. It also will not
  1406. teach you how to use your operating system or command-line interpreter.
  1407.  
  1408. The MySQL Database Software is under constant development, and the
  1409. Reference Manual is updated frequently as well.  The most recent
  1410. version of the manual is available online in searchable form at
  1411. `http://dev.mysql.com/doc/'.  Other formats also are available,
  1412. including HTML, PDF, and Windows CHM versions.
  1413.  
  1414. The primary document is the Texinfo file.  The HTML version is produced
  1415. automatically using a modified version of `texi2html'.  The plain text
  1416. and Info versions are produced with `makeinfo'.  The PostScript version
  1417. is produced using `texi2dvi' and `dvips'.  The PDF version is produced
  1418. with `pdftex'.
  1419.  
  1420. If you have any suggestions concerning additions or corrections to this
  1421. manual, please send them to the documentation team at <docs@mysql.com>.
  1422.  
  1423. This manual was initially written by David Axmark and Michael "Monty"
  1424. Widenius. It is now maintained by the MySQL Documentation Team,
  1425. consisting of Arjen Lentz, Paul DuBois, and Stefan Hinz.  For the many
  1426. other contributors, see *Note Credits::.
  1427.  
  1428. The copyright (2004) to this manual is owned by the Swedish company
  1429. MySQL AB. *Note Copyright::.  MySQL and the MySQL logo are (registered)
  1430. trademarks of MySQL AB.  Other trademarks and registered trademarks
  1431. referred to in this manual are the property of their respective owners,
  1432. and are used for identification purposes only.
  1433.  
  1434. Conventions Used in This Manual
  1435. -------------------------------
  1436.  
  1437. This manual uses certain typographical conventions:
  1438.  
  1439. `constant'
  1440.      Constant-width font is used for command names and options; SQL
  1441.      statements; database, table, and column names; C and Perl code;
  1442.      and environment variables.  Example: "To see how `mysqladmin'
  1443.      works, invoke it with the `--help' option."
  1444.  
  1445. CONSTANT ITALIC
  1446.      Italic constant-width font is used to indicate variable input for
  1447.      which you should substitute a value of your own choosing.
  1448.  
  1449. `filename'
  1450.      Constant-width font with surrounding quotes is used for filenames
  1451.      and pathnames.  Example: "The distribution is installed under the
  1452.      `/usr/local/' directory."
  1453.  
  1454. `c'
  1455.      Constant-width font with surrounding quotes is also used to
  1456.      indicate character sequences.  Example: "To specify a wildcard,
  1457.      use the `%' character."
  1458.  
  1459. _italic_
  1460.      Italic font is used for emphasis, _like this_.
  1461.  
  1462. *boldface*
  1463.      Boldface font is used in table headings and to convey *especially
  1464.      strong emphasis*.
  1465.  
  1466. When commands are shown that are meant to be executed from within a
  1467. particular program, the program is indicated by a prompt shown before
  1468. the command.  For example, `shell>' indicates a command that you
  1469. execute from your login shell, and `mysql>' indicates a statement that
  1470. you execute from the `mysql' client program:
  1471.  
  1472.      shell> type a shell command here
  1473.      mysql> type a mysql statement here
  1474.  
  1475. The "shell" is your command interpreter. On Unix, this is typically a
  1476. program such as `sh' or `csh'. On Windows, the equivalent program is
  1477. `command.com' or `cmd.exe', typically run in a console window.
  1478.  
  1479. When you enter a command or statement shown in an example, do not type
  1480. the prompt shown in the example.
  1481.  
  1482. Database, table, and column names must often be substituted into
  1483. statements.  To indicate that such substitution is necessary, this
  1484. manual uses DB_NAME, TBL_NAME, and COL_NAME.  For example, you might
  1485. see a statement like this:
  1486.  
  1487.      mysql> SELECT COL_NAME FROM DB_NAME.TBL_NAME;
  1488.  
  1489. This means that if you were to enter a similar statement, you would
  1490. supply your own database, table, and column names, perhaps like this:
  1491.  
  1492.      mysql> SELECT author_name FROM biblio_db.author_list;
  1493.  
  1494. SQL keywords are not case sensitive and may be written in uppercase or
  1495. lowercase.  This manual uses uppercase.
  1496.  
  1497. In syntax descriptions, square brackets (`[' and `]') are used to
  1498. indicate optional words or clauses.  For example, in the following
  1499. statement, `IF EXISTS' is optional:
  1500.  
  1501.      DROP TABLE [IF EXISTS] TBL_NAME
  1502.  
  1503. When a syntax element consists of a number of alternatives, the
  1504. alternatives are separated by vertical bars (`|').  When one member
  1505. from a set of choices _may_ be chosen, the alternatives are listed
  1506. within square brackets (`[' and `]'):
  1507.  
  1508.      TRIM([[BOTH | LEADING | TRAILING] [REMSTR] FROM] STR)
  1509.  
  1510. When one member from a set of choices _must_ be chosen, the
  1511. alternatives are listed within braces (`{' and `}'):
  1512.  
  1513.      {DESCRIBE | DESC} TBL_NAME [COL_NAME | WILD]
  1514.  
  1515. An ellipsis (`...') indicates the omission of a section of a statement,
  1516. typically to provide a shorter version of more complex syntax. For
  1517. example, `INSERT ... SELECT' is shorthand for the form of `INSERT'
  1518. statement that is followed by a `SELECT' statement.
  1519.  
  1520. An ellipsis can also indicate that the preceding syntax element of a
  1521. statement may be repeated. In the following example, multiple
  1522. RESET_OPTION values may be given, with each of those after the first
  1523. preceded by commas:
  1524.  
  1525.      RESET RESET_OPTION [,RESET_OPTION] ...
  1526.  
  1527. Commands for setting shell variables are shown using Bourne shell
  1528. syntax.  For example, the sequence to set an environment variable and
  1529. run a command looks like this in Bourne shell syntax:
  1530.  
  1531.      shell> VARNAME=VALUE SOME_COMMAND
  1532.  
  1533. If you are using `csh' or `tcsh', you must issue commands somewhat
  1534. differently.  You would execute the sequence just shown like this:
  1535.  
  1536.      shell> setenv VARNAME VALUE
  1537.      shell> SOME_COMMAND
  1538.  
  1539. Overview of the MySQL Database Management System
  1540. ================================================
  1541.  
  1542. MySQL, the most popular Open Source SQL database management system, is
  1543. developed, distributed, and supported by MySQL AB.  MySQL AB is a
  1544. commercial company, founded by the MySQL developers.  It is a second
  1545. generation open source company that unites open source values and
  1546. methodology with a successful business model.  *Note What is MySQL AB::.
  1547.  
  1548. The MySQL Web site (`http://www.mysql.com/') provides the latest
  1549. information about MySQL software and MySQL AB.
  1550.  
  1551. MySQL is a database management system.
  1552.      A database is a structured collection of data.  It may be anything
  1553.      from a simple shopping list to a picture gallery or the vast
  1554.      amounts of information in a corporate network.  To add, access,
  1555.      and process data stored in a computer database, you need a
  1556.      database management system such as MySQL Server.  Since computers
  1557.      are very good at handling large amounts of data, database
  1558.      management systems play a central role in computing, as standalone
  1559.      utilities or as parts of other applications.
  1560.  
  1561. MySQL is a relational database management system.
  1562.      A relational database stores data in separate tables rather than
  1563.      putting all the data in one big storeroom.  This adds speed and
  1564.      flexibility.  The SQL part of "MySQL" stands for "Structured Query
  1565.      Language." SQL is the most common standardized language used to
  1566.      access databases and is defined by the ANSI/ISO SQL Standard. The
  1567.      SQL standard has been evolving since 1986 and several versions
  1568.      exist. In this manual, "SQL-92" refers to the standard released in
  1569.      1992, "SQL:1999" refers to the standard released in 1999, and
  1570.      "SQL:2003" refers to the current version of the standard.  We use
  1571.      the phrase "the SQL standard" to mean the current version of the
  1572.      SQL Standard at any time.
  1573.  
  1574. MySQL software is Open Source.
  1575.      Open Source means that it is possible for anyone to use and modify
  1576.      the software.  Anybody can download the MySQL software from the
  1577.      Internet and use it without paying anything.  If you wish, you may
  1578.      study the source code and change it to suit your needs.  The MySQL
  1579.      software uses the GPL (GNU General Public License),
  1580.      `http://www.fsf.org/licenses/', to define what you may and may not
  1581.      do with the software in different situations.  If you feel
  1582.      uncomfortable with the GPL or need to embed MySQL code into a
  1583.      commercial application, you can buy a commercially licensed
  1584.      version from us.  *Note MySQL licenses::.
  1585.  
  1586. The MySQL Database Server is very fast, reliable, and easy to use.
  1587.      If that is what you are looking for, you should give it a try.
  1588.      MySQL Server also has a practical set of features developed in
  1589.      close cooperation with our users.  You can find a performance
  1590.      comparison of MySQL Server with other database managers on our
  1591.      benchmark page.  *Note MySQL Benchmarks::.
  1592.  
  1593.      MySQL Server was originally developed to handle large databases
  1594.      much faster than existing solutions and has been successfully used
  1595.      in highly demanding production environments for several years.
  1596.      Although under constant development, MySQL Server today offers a
  1597.      rich and useful set of functions.  Its connectivity, speed, and
  1598.      security make MySQL Server highly suited for accessing databases
  1599.      on the Internet.
  1600.  
  1601. MySQL Server works in client/server or embedded systems.
  1602.      The MySQL Database Software is a client/server system that consists
  1603.      of a multi-threaded SQL server that supports different backends,
  1604.      several different client programs and libraries, administrative
  1605.      tools, and a wide range of application programming interfaces
  1606.      (APIs).
  1607.  
  1608.      We also provide MySQL Server as an embedded multi-threaded library
  1609.      that you can link into your application to get a smaller, faster,
  1610.      easier-to-manage product.
  1611.  
  1612. A large amount of contributed MySQL software is available.
  1613.      It is very likely that you will find that your favorite
  1614.      application or language already supports the MySQL Database Server.
  1615.  
  1616. The official way to pronounce "MySQL" is "My Ess Que Ell" (not "my
  1617. sequel"), but we don't mind if you pronounce it as "my sequel" or in
  1618. some other localized way.
  1619.  
  1620. History of MySQL
  1621. ----------------
  1622.  
  1623. We started out with the intention of using `mSQL' to connect to our
  1624. tables using our own fast low-level (ISAM) routines. However, after some
  1625. testing, we came to the conclusion that `mSQL' was not fast enough or
  1626. flexible enough for our needs.  This resulted in a new SQL interface to
  1627. our database but with almost the same API interface as `mSQL'.  This
  1628. API was designed to allow third-party code that was written for use
  1629. with `mSQL' to be ported easily for use with MySQL.
  1630.  
  1631. The derivation of the name MySQL is not clear.  Our base directory and
  1632. a large number of our libraries and tools have had the prefix "my" for
  1633. well over 10 years.  However, co-founder Monty Widenius's daughter is
  1634. also named My.  Which of the two gave its name to MySQL is still a
  1635. mystery, even for us.
  1636.  
  1637. The name of the MySQL Dolphin (our logo) is "Sakila," which was chosen
  1638. by the founders of MySQL AB from a huge list of names suggested by users
  1639. in our "Name the Dolphin" contest. The winning name was submitted by
  1640. Ambrose Twebaze, an Open Source software developer from Swaziland,
  1641. Africa.  According to Ambrose, the name Sakila has its roots in
  1642. SiSwati, the local language of Swaziland. Sakila is also the name of a
  1643. town in Arusha, Tanzania, near Ambrose's country of origin, Uganda.
  1644.  
  1645. The Main Features of MySQL
  1646. --------------------------
  1647.  
  1648. The following list describes some of the important characteristics of
  1649. the MySQL Database Software. See also *Note Roadmap:: for more
  1650. information about current and upcoming features.
  1651.  
  1652. Internals and Portability
  1653.         * Written in C and C++.
  1654.  
  1655.         * Tested with a broad range of different compilers.
  1656.  
  1657.         * Works on many different platforms.  *Note Which OS::.
  1658.  
  1659.         * Uses GNU Automake, Autoconf, and Libtool for portability.
  1660.  
  1661.         * APIs for C, C++, Eiffel, Java, Perl, PHP, Python, Ruby, and
  1662.           Tcl are available.  *Note Clients::.
  1663.  
  1664.         * Fully multi-threaded using kernel threads.  It can easily use
  1665.           multiple CPUs if they are available.
  1666.  
  1667.         * Provides transactional and non-transactional storage engines.
  1668.  
  1669.         * Uses very fast B-tree disk tables (`MyISAM') with index
  1670.           compression.
  1671.  
  1672.         * Relatively easy to add another storage engine. This is useful
  1673.           if you want to add an SQL interface to an in-house database.
  1674.  
  1675.         * A very fast thread-based memory allocation system.
  1676.  
  1677.         * Very fast joins using an optimized one-sweep multi-join.
  1678.  
  1679.         * In-memory hash tables, which are used as temporary tables.
  1680.  
  1681.         * SQL functions are implemented using a highly optimized class
  1682.           library and should be as fast as possible.  Usually there is
  1683.           no memory allocation at all after query initialization.
  1684.  
  1685.         * The MySQL code is tested with Purify (a commercial memory
  1686.           leakage detector) as well as with Valgrind, a GPL tool
  1687.           (`http://developer.kde.org/~sewardj/').
  1688.  
  1689.         * The server is available as a separate program for use in a
  1690.           client/server networked environment.  It is also available as
  1691.           a library that can be embedded (linked) into standalone
  1692.           applications. Such applications can be used in isolation or
  1693.           in environments where no network is available.
  1694.  
  1695. Column Types
  1696.         * Many column types: signed/unsigned integers 1, 2, 3, 4, and 8
  1697.           bytes long, `FLOAT', `DOUBLE', `CHAR', `VARCHAR', `TEXT',
  1698.           `BLOB', `DATE', `TIME', `DATETIME', `TIMESTAMP', `YEAR',
  1699.           `SET', `ENUM', and OpenGIS spatial types.  *Note Column
  1700.           types::.
  1701.  
  1702.         * Fixed-length and variable-length records.
  1703.  
  1704. Statements and Functions
  1705.         * Full operator and function support in the `SELECT' and `WHERE'
  1706.           clauses of queries.  For example:
  1707.  
  1708.                mysql> SELECT CONCAT(first_name, ' ', last_name)
  1709.                    -> FROM citizen
  1710.                    -> WHERE income/dependents > 10000 AND age > 30;
  1711.  
  1712.         * Full support for SQL `GROUP BY' and `ORDER BY' clauses.
  1713.           Support for group functions (`COUNT()', `COUNT(DISTINCT ...)',
  1714.           `AVG()', `STD()', `SUM()', `MAX()', `MIN()', and
  1715.           `GROUP_CONCAT()').
  1716.  
  1717.         * Support for `LEFT OUTER JOIN' and `RIGHT OUTER JOIN' with
  1718.           both standard SQL and ODBC syntax.
  1719.  
  1720.         * Support for aliases on tables and columns as required by
  1721.           standard SQL.
  1722.  
  1723.         * `DELETE', `INSERT', `REPLACE', and `UPDATE' return the number
  1724.           of rows that were changed (affected).  It is possible to
  1725.           return the number of rows matched instead by setting a flag
  1726.           when connecting to the server.
  1727.  
  1728.         * The MySQL-specific `SHOW' command can be used to retrieve
  1729.           information about databases, tables, and indexes.  The
  1730.           `EXPLAIN' command can be used to determine how the optimizer
  1731.           resolves a query.
  1732.  
  1733.         * Function names do not clash with table or column names.  For
  1734.           example, `ABS' is a valid column name.  The only restriction
  1735.           is that for a function call, no spaces are allowed between
  1736.           the function name and the `(' that follows it.  *Note
  1737.           Reserved words::.
  1738.  
  1739.         * You can mix tables from different databases in the same query
  1740.           (as of MySQL 3.22).
  1741.  
  1742. Security
  1743.         * A privilege and password system that is very flexible and
  1744.           secure, and that allows host-based verification.  Passwords
  1745.           are secure because all password traffic is encrypted when you
  1746.           connect to a server.
  1747.  
  1748. Scalability and Limits
  1749.         * Handles large databases.  We use MySQL Server with databases
  1750.           that contain 50 million records. We also know of users who
  1751.           use MySQL Server with 60,000 tables and about 5,000,000,000
  1752.           rows.
  1753.  
  1754.         * Up to 64 indexes per table are allowed (32 before MySQL
  1755.           4.1.2).  Each index may consist of 1 to 16 columns or parts
  1756.           of columns.  The maximum index width is 1000 bytes (500
  1757.           before MySQL 4.1.2).  An index may use a prefix of a column
  1758.           for `CHAR', `VARCHAR', `BLOB', or `TEXT' column types.
  1759.  
  1760. Connectivity
  1761.         * Clients can connect to the MySQL server using TCP/IP sockets
  1762.           on any platform.  On Windows systems in the NT family (NT,
  1763.           2000, or XP), clients can connect using named pipes. On Unix
  1764.           systems, clients can connect using Unix domain socket files.
  1765.  
  1766.         * The Connector/ODBC interface provides MySQL support for
  1767.           client programs that use ODBC (Open Database Connectivity)
  1768.           connections.  For example, you can use MS Access to connect
  1769.           to your MySQL server.  Clients can be run on Windows or Unix.
  1770.           Connector/ODBC source is available.  All ODBC 2.5 functions
  1771.           are supported, as are many others.  *Note ODBC::.
  1772.  
  1773.         * The Connector/JDBC interface provides MySQL support for Java
  1774.           client programs that use JDBC connections.  Clients can be
  1775.           run on Windows or Unix.  Connector/JDBC source is available.
  1776.           *Note Java::.
  1777.  
  1778. Localization
  1779.         * The server can provide error messages to clients in many
  1780.           languages.  *Note Languages::.
  1781.  
  1782.         * Full support for several different character sets, including
  1783.           `latin1' (ISO-8859-1), `german', `big5', `ujis', and more.
  1784.           For example, the Scandinavian characters `a^', `a"' and `o"'
  1785.           are allowed in table and column names.  Unicode support is
  1786.           available as of MySQL 4.1.
  1787.  
  1788.         * All data is saved in the chosen character set.  All
  1789.           comparisons for normal string columns are case-insensitive.
  1790.  
  1791.         * Sorting is done according to the chosen character set (using
  1792.           Swedish collation by default).  It is possible to change this
  1793.           when the MySQL server is started.  To see an example of very
  1794.           advanced sorting, look at the Czech sorting code.  MySQL
  1795.           Server supports many different character sets that can be
  1796.           specified at compile time and runtime.
  1797.  
  1798. Clients and Tools
  1799.         * The MySQL server has built-in support for SQL statements to
  1800.           check, optimize, and repair tables.  These statements are
  1801.           available from the command line through the `mysqlcheck'
  1802.           client. MySQL also includes `myisamchk', a very fast
  1803.           command-line utility for performing these operations on
  1804.           `MyISAM' tables.  *Note MySQL Database Administration::.
  1805.  
  1806.         * All MySQL programs can be invoked with the `--help' or `-?'
  1807.           options to obtain online assistance.
  1808.  
  1809. MySQL Stability
  1810. ---------------
  1811.  
  1812. This section addresses the questions, "_How stable is MySQL Server?_"
  1813. and, "_Can I depend on MySQL Server in this project?_" We will try to
  1814. clarify these issues and answer some important questions that concern
  1815. many potential users. The information in this section is based on data
  1816. gathered from the mailing lists, which are very active in identifying
  1817. problems as well as reporting types of use.
  1818.  
  1819. The original code stems back to the early 1980s. It provides a stable
  1820. code base, and the `ISAM' table format used by the original storage
  1821. engine remains backward-compatible.  At TcX, the predecessor of MySQL
  1822. AB, MySQL code has worked in projects since mid-1996, without any
  1823. problems.  When the MySQL Database Software initially was released to a
  1824. wider public, our new users quickly found some pieces of untested code.
  1825. Each new release since then has had fewer portability problems, even
  1826. though each new release has also had many new features.
  1827.  
  1828. Each release of the MySQL Server has been usable. Problems have occurred
  1829. only when users try code from the "gray zones."  Naturally, new users
  1830. don't know what the gray zones are; this section therefore attempts to
  1831. document those areas that are currently known.  The descriptions mostly
  1832. deal with Version 3.23 and 4.0 of MySQL Server.  All known and reported
  1833. bugs are fixed in the latest version, with the exception of those
  1834. listed in the bugs section, which are design-related.  *Note Bugs::.
  1835.  
  1836. The MySQL Server design is multi-layered with independent modules.
  1837. Some of the newer modules are listed here with an indication of how
  1838. well-tested each of them is:
  1839.  
  1840. Replication (Gamma)
  1841.      Large groups of servers using replication are in production use,
  1842.      with good results. Work on enhanced replication features is
  1843.      continuing in MySQL 5.x.
  1844.  
  1845. `InnoDB' tables (Stable)
  1846.      The `InnoDB' transactional storage engine has been declared stable
  1847.      in the MySQL 3.23 tree, starting from version 3.23.49.  `InnoDB'
  1848.      is being used in large, heavy-load production systems.
  1849.  
  1850. `BDB' tables (Gamma)
  1851.      The `Berkeley DB' code is very stable, but we are still improving
  1852.      the `BDB' transactional storage engine interface in MySQL Server,
  1853.      so it will take some time before this is as well tested as the
  1854.      other table types.
  1855.  
  1856. Full-text searches (Beta)
  1857.      Full-text searching works but is not yet widely used.  Important
  1858.      enhancements have been implemented in MySQL 4.0.
  1859.  
  1860. `Connector/ODBC' 3.51 (Stable)
  1861.      `Connector/ODBC' 3.51 uses ODBC SDK 3.51 and is in wide production
  1862.      use.  Some issues brought up appear to be application-related and
  1863.      independent of the ODBC driver or underlying database server.
  1864.  
  1865. Automatic recovery of `MyISAM' tables (Gamma)
  1866.      This status applies only to the new code in the `MyISAM' storage
  1867.      engine that checks when opening a table whether it was closed
  1868.      properly and executes an automatic check or repair of the table if
  1869.      it wasn't.
  1870.  
  1871. How Big MySQL Tables Can Be
  1872. ---------------------------
  1873.  
  1874. MySQL 3.22 had a 4GB (4 gigabyte) limit on table size. With the
  1875. `MyISAM' storage engine in MySQL 3.23, the maximum table size was
  1876. increased to 8 million terabytes (2 ^ 63 bytes). With this larger
  1877. allowed table size, the maximum effective table size for MySQL
  1878. databases now usually is determined by operating system constraints on
  1879. file sizes, not by MySQL internal limits.
  1880.  
  1881. The `InnoDB' storage engine maintains `InnoDB' tables within a
  1882. tablespace that can be created from several files. This allows a table
  1883. to exceed the maximum individual file size. The tablespace can include
  1884. raw disk partitions, which allows extremely large tables. The maximum
  1885. tablespace size is 64TB.
  1886.  
  1887. The following table lists some examples of operating system file-size
  1888. limits:
  1889.  
  1890. *Operating System*     *File-size Limit*
  1891. Linux-Intel 32-bit     2GB, much more when using LFS
  1892. Linux-Alpha            8TB (?)
  1893. Solaris 2.5.1          2GB (4GB possible with patch)
  1894. Solaris 2.6            4GB (can be changed with flag)
  1895. Solaris 2.7 Intel      4GB
  1896. Solaris 2.7            512GB
  1897. UltraSPARC             
  1898. NetWare w/NSS          8TB
  1899. filesystem             
  1900.  
  1901. On Linux 2.2, you can get `MyISAM' tables larger than 2GB in size by
  1902. using the Large File Support (LFS) patch for the ext2 filesystem. On
  1903. Linux 2.4, patches also exist for ReiserFS to get support for big
  1904. files. Most current Linux distributions are based on kernel 2.4 and
  1905. already include all the required LFS patches. However, the maximum
  1906. available file size still depends on several factors, one of them being
  1907. the filesystem used to store MySQL tables.
  1908.  
  1909. For a detailed overview about LFS in Linux, have a look at Andreas
  1910. Jaeger's `Large File Support in Linux' page at
  1911. `http://www.suse.de/~aj/linux_lfs.html'.
  1912.  
  1913. By default, MySQL creates `MyISAM' tables with an internal structure
  1914. that allows a maximum size of about 4GB.  You can check the maximum
  1915. table size for a table with the `SHOW TABLE STATUS' statement or with
  1916. `myisamchk -dv TBL_NAME'.  *Note `SHOW': SHOW.
  1917.  
  1918. If you need a `MyISAM' table that will be larger than 4GB in size (and
  1919. your operating system supports large files), the `CREATE TABLE'
  1920. statement allows `AVG_ROW_LENGTH' and `MAX_ROWS' options.  *Note
  1921. `CREATE TABLE': CREATE TABLE.  You can also change these options with
  1922. `ALTER TABLE' after the table has been created, to increase the table's
  1923. maximum allowable size.  *Note `ALTER TABLE': ALTER TABLE.
  1924.  
  1925. Other ways to work around file-size limits for `MyISAM' tables are as
  1926. follows:
  1927.  
  1928.    * If your large table is read-only, you can use `myisampack' to
  1929.      compress it.  `myisampack' usually compresses a table by at least
  1930.      50%, so you can have, in effect, much bigger tables.  `myisampack'
  1931.      also can merge multiple tables into a single table.  *Note
  1932.      `myisampack': myisampack.
  1933.  
  1934.    * Another way to get around the operating system file limit for
  1935.      `MyISAM' data files is by using the `RAID' options.  *Note `CREATE
  1936.      TABLE': CREATE TABLE.
  1937.  
  1938.    * MySQL includes a `MERGE' library that allows you to handle a
  1939.      collection of `MyISAM' tables that have identical structure as a
  1940.      single `MERGE' table.  *Note `MERGE' tables: MERGE.
  1941.  
  1942.  
  1943. Year 2000 Compliance
  1944. --------------------
  1945.  
  1946. The MySQL Server itself has no problems with Year 2000 (Y2K) compliance:
  1947.  
  1948.    * MySQL Server uses Unix time functions that handle dates into the
  1949.      year `2037' for `TIMESTAMP' values. For `DATE' and `DATETIME'
  1950.      values, dates through the year `9999' are accepted.
  1951.  
  1952.    * All MySQL date functions are implemented in one source file,
  1953.      `sql/time.cc', and are coded very carefully to be year 2000-safe.
  1954.  
  1955.    * In MySQL 3.22 and later, the `YEAR' column type can store years
  1956.      `0' and `1901' to `2155' in one byte and display them using two or
  1957.      four digits.  All two-digit years are considered to be in the range
  1958.      `1970' to `2069', which means that if you store `01' in a `YEAR'
  1959.      column, MySQL Server treats it as `2001'.
  1960.  
  1961. The following simple demonstration illustrates that MySQL Server has no
  1962. problems with `DATE' or `DATETIME' values through the year 9999, and no
  1963. problems with `TIMESTAMP' values until after the year 2030:
  1964.  
  1965.      mysql> DROP TABLE IF EXISTS y2k;
  1966.      Query OK, 0 rows affected (0.01 sec)
  1967.      
  1968.      mysql> CREATE TABLE y2k (date DATE,
  1969.          ->                   date_time DATETIME,
  1970.          ->                   time_stamp TIMESTAMP);
  1971.      Query OK, 0 rows affected (0.01 sec)
  1972.      
  1973.      mysql> INSERT INTO y2k VALUES
  1974.          -> ('1998-12-31','1998-12-31 23:59:59',19981231235959),
  1975.          -> ('1999-01-01','1999-01-01 00:00:00',19990101000000),
  1976.          -> ('1999-09-09','1999-09-09 23:59:59',19990909235959),
  1977.          -> ('2000-01-01','2000-01-01 00:00:00',20000101000000),
  1978.          -> ('2000-02-28','2000-02-28 00:00:00',20000228000000),
  1979.          -> ('2000-02-29','2000-02-29 00:00:00',20000229000000),
  1980.          -> ('2000-03-01','2000-03-01 00:00:00',20000301000000),
  1981.          -> ('2000-12-31','2000-12-31 23:59:59',20001231235959),
  1982.          -> ('2001-01-01','2001-01-01 00:00:00',20010101000000),
  1983.          -> ('2004-12-31','2004-12-31 23:59:59',20041231235959),
  1984.          -> ('2005-01-01','2005-01-01 00:00:00',20050101000000),
  1985.          -> ('2030-01-01','2030-01-01 00:00:00',20300101000000),
  1986.          -> ('2040-01-01','2040-01-01 00:00:00',20400101000000),
  1987.          -> ('9999-12-31','9999-12-31 23:59:59',99991231235959);
  1988.      Query OK, 14 rows affected (0.01 sec)
  1989.      Records: 14  Duplicates: 0  Warnings: 2
  1990.      
  1991.      mysql> SELECT * FROM y2k;
  1992.      +------------+---------------------+----------------+
  1993.      | date       | date_time           | time_stamp     |
  1994.      +------------+---------------------+----------------+
  1995.      | 1998-12-31 | 1998-12-31 23:59:59 | 19981231235959 |
  1996.      | 1999-01-01 | 1999-01-01 00:00:00 | 19990101000000 |
  1997.      | 1999-09-09 | 1999-09-09 23:59:59 | 19990909235959 |
  1998.      | 2000-01-01 | 2000-01-01 00:00:00 | 20000101000000 |
  1999.      | 2000-02-28 | 2000-02-28 00:00:00 | 20000228000000 |
  2000.      | 2000-02-29 | 2000-02-29 00:00:00 | 20000229000000 |
  2001.      | 2000-03-01 | 2000-03-01 00:00:00 | 20000301000000 |
  2002.      | 2000-12-31 | 2000-12-31 23:59:59 | 20001231235959 |
  2003.      | 2001-01-01 | 2001-01-01 00:00:00 | 20010101000000 |
  2004.      | 2004-12-31 | 2004-12-31 23:59:59 | 20041231235959 |
  2005.      | 2005-01-01 | 2005-01-01 00:00:00 | 20050101000000 |
  2006.      | 2030-01-01 | 2030-01-01 00:00:00 | 20300101000000 |
  2007.      | 2040-01-01 | 2040-01-01 00:00:00 | 00000000000000 |
  2008.      | 9999-12-31 | 9999-12-31 23:59:59 | 00000000000000 |
  2009.      +------------+---------------------+----------------+
  2010.      14 rows in set (0.00 sec)
  2011.  
  2012. The final two `TIMESTAMP' column values are zero because the year
  2013. values (`2040', `9999') exceed the `TIMESTAMP' maximum.  The
  2014. `TIMESTAMP' data type, which is used to store the current time,
  2015. supports values that range from `19700101000000' to `20300101000000' on
  2016. 32-bit machines (signed value).  On 64-bit machines, `TIMESTAMP'
  2017. handles values up to `2106' (unsigned value).
  2018.  
  2019. Although MySQL Server itself is Y2K-safe, you may run into problems if
  2020. you use it with applications that are not Y2K-safe.  For example, many
  2021. old applications store or manipulate years using two-digit values
  2022. (which are ambiguous) rather than four-digit values.  This problem may
  2023. be compounded by applications that use values such as `00' or `99' as
  2024. "missing" value indicators.  Unfortunately, these problems may be
  2025. difficult to fix because different applications may be written by
  2026. different programmers, each of whom may use a different set of
  2027. conventions and date-handling functions.
  2028.  
  2029. Thus, even though MySQL Server has no Y2K problems, it is the
  2030. application's responsibility to provide unambiguous input.  See *Note
  2031. Y2K issues:: for MySQL Server's rules for dealing with ambiguous date
  2032. input data that contains two-digit year values.
  2033.  
  2034. Overview of MySQL AB
  2035. ====================
  2036.  
  2037. MySQL AB is the company of the MySQL founders and main developers.
  2038. MySQL AB was originally established in Sweden by David Axmark, Allan
  2039. Larsson, and Michael "Monty" Widenius.
  2040.  
  2041. The developers of the MySQL server are all employed by the company.  We
  2042. are a virtual organization with people in a dozen countries around the
  2043. world. We communicate extensively over the Internet every day with one
  2044. another and with our users, supporters, and partners.
  2045.  
  2046. We are dedicated to developing the MySQL database software and
  2047. promoting it to new users. MySQL AB owns the copyright to the MySQL
  2048. source code, the MySQL logo and (registered) trademark, and this
  2049. manual. *Note What-is::.
  2050.  
  2051. The MySQL core values show our dedication to MySQL and Open Source.
  2052.  
  2053. These core values direct how MySQL AB works with the MySQL server
  2054. software:
  2055.  
  2056.    * To be the best and the most widely used database in the world
  2057.  
  2058.    * To be available and affordable by all
  2059.  
  2060.    * To be easy to use
  2061.  
  2062.    * To be continuously improved while remaining fast and safe
  2063.  
  2064.    * To be fun to use and improve
  2065.  
  2066.    * To be free from bugs
  2067.  
  2068. These are the core values of the company MySQL AB and its employees:
  2069.  
  2070.    * We subscribe to the Open Source philosophy and support the Open
  2071.      Source community
  2072.  
  2073.    * We aim to be good citizens
  2074.  
  2075.    * We prefer partners that share our values and mindset
  2076.  
  2077.    * We answer email and provide support
  2078.  
  2079.    * We are a virtual company, networking with others
  2080.  
  2081.    * We work against software patents
  2082.  
  2083. The MySQL Web site (`http://www.mysql.com/') provides the latest
  2084. information about MySQL and MySQL AB.
  2085.  
  2086. By the way, the "AB" part of the company name is the acronym for the
  2087. Swedish "aktiebolag," or "stock company." It translates to "MySQL,
  2088. Inc." In fact, MySQL, Inc. and MySQL GmbH are examples of MySQL AB
  2089. subsidiaries. They are located in the US and Germany, respectively.
  2090.  
  2091. The Business Model and Services of MySQL AB
  2092. -------------------------------------------
  2093.  
  2094. One of the most common questions we encounter is, "_How can you make a
  2095. living from something you give away for free?_" This is how:
  2096.  
  2097.    * MySQL AB makes money on support, services, commercial licenses,
  2098.      and royalties.
  2099.  
  2100.    * We use these revenues to fund product development and to expand
  2101.      the MySQL business.
  2102.  
  2103. The company has been profitable since its inception. In October 2001,
  2104. we accepted venture financing from leading Scandinavian investors and a
  2105. handful of business angels. This investment is used to solidify our
  2106. business model and build a basis for sustainable growth.
  2107.  
  2108. Support
  2109. .......
  2110.  
  2111. MySQL AB is run and owned by the founders and main developers of the
  2112. MySQL database. The developers are committed to providing support to
  2113. customers and other users in order to stay in touch with their needs
  2114. and problems. All our support is provided by qualified developers.
  2115. Really tricky questions are answered by Michael "Monty" Widenius,
  2116. principal author of the MySQL Server.
  2117.  
  2118. Paying customers receive high-quality support directly from MySQL AB.
  2119. MySQL AB also provides the MySQL mailing lists as a community resource
  2120. where anyone may ask questions.
  2121.  
  2122. For more information and ordering support at various levels, see *Note
  2123. Licensing and Support::.
  2124.  
  2125. Training and Certification
  2126. ..........................
  2127.  
  2128. MySQL AB delivers MySQL and related training worldwide.  We offer both
  2129. open courses and in-house courses tailored to the specific needs of
  2130. your company. MySQL Training is also available through our partners,
  2131. the Authorized MySQL Training Centers.
  2132.  
  2133. Our training material uses the same sample databases used in our
  2134. documentation and our sample applications, and is always updated to
  2135. reflect the latest MySQL version. Our trainers are backed by the
  2136. development team to guarantee the quality of the training and the
  2137. continuous development of the course material. This also ensures that
  2138. no questions raised during the courses remain unanswered.
  2139.  
  2140. Attending our training courses will enable you to achieve your MySQL
  2141. application goals. You will also:
  2142.    * Save time
  2143.  
  2144.    * Improve the performance of your applications
  2145.  
  2146.    * Reduce or eliminate the need for additional hardware, decreasing
  2147.      cost
  2148.  
  2149.    * Enhance security.
  2150.  
  2151.    * Increase customer and co-worker satisfaction
  2152.  
  2153.    * Prepare yourself for MySQL Certification
  2154.  
  2155. If you are interested in our training as a potential participant or as
  2156. a training partner, please visit the training section at
  2157. `http://www.mysql.com/training/', or send email to <training@mysql.com>.
  2158.  
  2159. For details about the MySQL Certification Program, please see
  2160. `http://www.mysql.com/certification/'.
  2161.  
  2162. Consulting
  2163. ..........
  2164.  
  2165. MySQL AB and its Authorized Partners offer consulting services to users
  2166. of MySQL Server and to those who embed MySQL Server in their own
  2167. software, all over the world.
  2168.  
  2169. Our consultants can help you design and tune your databases, construct
  2170. efficient queries, tune your platform for optimal performance, resolve
  2171. migration issues, set up replication, build robust transactional
  2172. applications, and more.  We also help customers embed MySQL Server in
  2173. their products and applications for large-scale deployment.
  2174.  
  2175. Our consultants work in close collaboration with our development team,
  2176. which ensures the technical quality of our professional services.
  2177. Consulting assignments range from two-day power-start sessions to
  2178. projects that span weeks and months. Our expertise covers not only
  2179. MySQL Server, it also extends into programming and scripting languages
  2180. such as PHP, Perl, and more.
  2181.  
  2182. If you are interested in our consulting services or want to become a
  2183. consulting partner, please visit the consulting section of our Web site
  2184. at `http://www.mysql.com/consulting/' or contact our consulting staff
  2185. at <consulting@mysql.com>.
  2186.  
  2187. Commercial Licenses
  2188. ...................
  2189.  
  2190. The MySQL database is released under the GNU General Public License
  2191. (GPL).  This means that the MySQL software can be used free of charge
  2192. under the GPL. If you do not want to be bound by the GPL terms (such as
  2193. the requirement that your application must also be GPL), you may
  2194. purchase a commercial license for the same product from MySQL AB; see
  2195. `https://order.mysql.com/'.  Since MySQL AB owns the copyright to the
  2196. MySQL source code, we are able to employ Dual Licensing, which means
  2197. that the same product is available under GPL and under a commercial
  2198. license. This does not in any way affect the Open Source commitment of
  2199. MySQL AB. For details about when a commercial license is required,
  2200. please see *Note MySQL licenses::.
  2201.  
  2202. We also sell commercial licenses of third-party Open Source GPL
  2203. software that adds value to MySQL Server. A good example is the
  2204. `InnoDB' transactional storage engine that offers `ACID' support,
  2205. row-level locking, crash recovery, multi-versioning, foreign key
  2206. support, and more. *Note InnoDB::.
  2207.  
  2208. Partnering
  2209. ..........
  2210.  
  2211. MySQL AB has a worldwide partner program that covers training courses,
  2212. consulting and support, publications, plus reselling and distributing
  2213. MySQL and related products. MySQL AB Partners get visibility on the
  2214. `http://www.mysql.com/' Web site and the right to use special versions
  2215. of the MySQL (registered) trademarks to identify their products and
  2216. promote their business.
  2217.  
  2218. If you are interested in becoming a MySQL AB Partner, please email
  2219. <partner@mysql.com>.
  2220.  
  2221. The word MySQL and the MySQL dolphin logo are (registered) trademarks
  2222. of MySQL AB. *Note MySQL AB Logos and Trademarks::.  These trademarks
  2223. represent a significant value that the MySQL founders have built over
  2224. the years.
  2225.  
  2226. The MySQL Web site (`http://www.mysql.com/') is popular among
  2227. developers and users. In December 2003, we served 16 million page views.
  2228. Our visitors represent a group that makes purchase decisions and
  2229. recommendations for both software and hardware. Twelve percent of our
  2230. visitors authorize purchase decisions, and only nine percent have no
  2231. involvement at all in purchase decisions. More than 65% have made one or
  2232. more online business purchases within the last half-year, and 70% plan
  2233. to make one in the next few months.
  2234.  
  2235. Contact Information
  2236. -------------------
  2237.  
  2238. The MySQL Web site (`http://www.mysql.com/') provides the latest
  2239. information about MySQL and MySQL AB.
  2240.  
  2241. For press services and inquiries not covered in our news releases
  2242. (`http://www.mysql.com/news-and-events/'), please send email to
  2243. <press@mysql.com>.
  2244.  
  2245. If you have a support contract with MySQL AB, you will get timely,
  2246. precise answers to your technical questions about the MySQL software.
  2247. For more information, see *Note Support::.  On our Web site, see
  2248. `http://www.mysql.com/support/', or send email to <sales@mysql.com>.
  2249.  
  2250. For information about MySQL training, please visit the training section
  2251. at `http://www.mysql.com/training/', or send email to
  2252. <training@mysql.com>.  *Note Business Services Training::.
  2253.  
  2254. For information on the MySQL Certification Program, please see
  2255. `http://www.mysql.com/certification/'.  *Note Business Services
  2256. Training::.
  2257.  
  2258. If you're interested in consulting, please visit the consulting section
  2259. of our Web site at `http://www.mysql.com/consulting/', or send email to
  2260. <consulting@mysql.com>.  *Note Business Services Consulting::.
  2261.  
  2262. Commercial licenses may be purchased online at
  2263. `https://order.mysql.com/'. There you will also find information on how
  2264. to fax your purchase order to MySQL AB. More information about
  2265. licensing can be found at `http://www.mysql.com/products/licensing/'.
  2266. If you have questions regarding licensing or you want a quote for
  2267. high-volume licensing, please fill in the contact form on our Web site
  2268. (`http://www.mysql.com/'), or send email to <licensing@mysql.com> (for
  2269. licensing questions) or to <sales@mysql.com> (for sales inquiries).
  2270. *Note MySQL licenses::.
  2271.  
  2272. If you represent a business that is interested in partnering with MySQL
  2273. AB, please send email to <partner@mysql.com>.  *Note Business Services
  2274. Partnering::.
  2275.  
  2276. For more information on the MySQL trademark policy, refer to
  2277. `http://www.mysql.com/company/trademark.html', or send email to
  2278. <trademark@mysql.com>.  *Note MySQL AB Logos and Trademarks::.
  2279.  
  2280. If you are interested in any of the MySQL AB jobs listed in our jobs
  2281. section (`http://www.mysql.com/company/jobs/'), please send email to
  2282. <jobs@mysql.com>.  Please do not send your CV as an attachment, but
  2283. rather as plain text at the end of your email message.
  2284.  
  2285. For general discussion among our many users, please direct your
  2286. attention to the appropriate mailing list.  *Note Questions::.
  2287.  
  2288. Reports of errors (often called "bugs"), as well as questions and
  2289. comments, should be sent to the general MySQL mailing list.  *Note
  2290. Mailing-list::.  If you have found a sensitive security bug in MySQL
  2291. Server, please let us know immediately by sending email to
  2292. <security@mysql.com>.  *Note Bug reports::.
  2293.  
  2294. If you have benchmark results that we can publish, please contact us
  2295. via email at <benchmarks@mysql.com>.
  2296.  
  2297. If you have suggestions concerning additions or corrections to this
  2298. manual, please send them to the documentation team via email at
  2299. <docs@mysql.com>.
  2300.  
  2301. For questions or comments about the workings or content of the MySQL
  2302. Web site (`http://www.mysql.com/'), please send email to
  2303. <webmaster@mysql.com>.
  2304.  
  2305. MySQL AB has a privacy policy, which can be read at
  2306. `http://www.mysql.com/company/privacy.html'.  For any queries regarding
  2307. this policy, please send email to <privacy@mysql.com>.
  2308.  
  2309. For all other inquiries, please send email to <info@mysql.com>.
  2310.  
  2311. MySQL Support and Licensing
  2312. ===========================
  2313.  
  2314. This section describes MySQL support and licensing arrangements.
  2315.  
  2316. Support Offered by MySQL AB
  2317. ---------------------------
  2318.  
  2319. Technical support from MySQL AB means individualized answers to your
  2320. unique problems direct from the software engineers who code the MySQL
  2321. database engine.
  2322.  
  2323. We try to take a broad and inclusive view of technical support. Almost
  2324. any problem involving MySQL software is important to us if it's
  2325. important to you.  Typically customers seek help on how to get
  2326. different commands and utilities to work, remove performance
  2327. bottlenecks, restore crashed systems, understand the impact of
  2328. operating system or networking issues on MySQL, set up best practices
  2329. for backup and recovery, utilize APIs, and so on.  Our support covers
  2330. only the MySQL server and our own utilities, not third-party products
  2331. that access the MySQL server, although we try to help with these where
  2332. we can.
  2333.  
  2334. Detailed information about our various support options is given at
  2335. `http://www.mysql.com/support/', where support contracts can also be
  2336. ordered online.  To contact our sales staff, send email to
  2337. <sales@mysql.com>.
  2338.  
  2339. Technical support is like life insurance. You can live happily without
  2340. it for years. However, when your hour arrives, it becomes critically
  2341. important, but it's too late to buy it.  If you use MySQL Server for
  2342. important applications and encounter sudden difficulties, it may be too
  2343. time-consuming to figure out all the answers yourself. You may need
  2344. immediate access to the most experienced MySQL troubleshooters
  2345. available, those employed by MySQL AB.
  2346.  
  2347. Copyrights and Licenses Used by MySQL
  2348. -------------------------------------
  2349.  
  2350. MySQL AB owns the copyright to the MySQL source code, the MySQL logos
  2351. and (registered) trademarks, and this manual.  *Note What is MySQL AB::.
  2352. Several different licenses are relevant to the MySQL distribution:
  2353.  
  2354.   1. All the MySQL-specific source in the server, the `mysqlclient'
  2355.      library and the client, as well as the GNU `readline' library, are
  2356.      covered by the GNU General Public License.  *Note GPL license::.
  2357.      The text of this license can be found as the file `COPYING' in
  2358.      MySQL distributions.
  2359.  
  2360.   2. The GNU `getopt' library is covered by the GNU Lesser General
  2361.      Public License.  See `http://www.fsf.org/licenses/'.
  2362.  
  2363.   3. Some parts of the source (the `regexp' library) are covered by a
  2364.      Berkeley-style copyright.
  2365.  
  2366.   4. Older versions of MySQL (3.22 and earlier) are subject to a
  2367.      stricter license
  2368.      (`http://www.mysql.com/products/licensing/mypl.html').  See the
  2369.      documentation of the specific version for information.
  2370.  
  2371.   5. The MySQL Reference Manual is _not_ distributed under a GPL-style
  2372.      license. Use of the manual is subject to the following terms:
  2373.         * Conversion to other formats is allowed, but the actual content
  2374.           may not be altered or edited in any way.
  2375.  
  2376.         * You may create a printed copy for your own personal use.
  2377.  
  2378.         * For all other uses, such as selling printed copies or using
  2379.           (parts of) the manual in another publication, prior written
  2380.           agreement from MySQL AB is required.
  2381.      Please send an email message to <docs@mysql.com> for more
  2382.      information or if you are interested in doing a translation.
  2383.  
  2384. For information about how the MySQL licenses work in practice, please
  2385. refer to *Note MySQL licenses:: and *Note MySQL AB Logos and
  2386. Trademarks::.
  2387.  
  2388. MySQL Licenses
  2389. --------------
  2390.  
  2391. The MySQL software is released under the GNU General Public License
  2392. (GPL), which is probably the best known Open Source license.  The
  2393. formal terms of the GPL license can be found at
  2394. `http://www.fsf.org/licenses/'.  See also
  2395. `http://www.fsf.org/licenses/gpl-faq.html' and
  2396. `http://www.gnu.org/philosophy/enforcing-gpl.html'.
  2397.  
  2398. Our GPL licensing is supported by an optional license exception that
  2399. enables many Free/Libre and Open Source Software ("FLOSS") applications
  2400. to include the GPL-licensed MySQL client libraries despite the fact
  2401. that not all FLOSS licenses are compatible with the GPL. For details,
  2402. see `http://www.mysql.com/products/licensing/foss-exception.html'.
  2403.  
  2404. Because the MySQL software is released under the GPL, it may often be
  2405. used for free, but for certain uses you may want or need to buy
  2406. commercial licenses from MySQL AB at `https://order.mysql.com/'.  See
  2407. `http://www.mysql.com/products/licensing/' for more information.
  2408.  
  2409. Older versions of MySQL (3.22 and earlier) are subject to a stricter
  2410. license (`http://www.mysql.com/products/licensing/mypl.html').  See the
  2411. documentation of the specific version for information.
  2412.  
  2413. Please note that the use of the MySQL software under commercial
  2414. license, GPL, or the old MySQL license does not automatically give you
  2415. the right to use MySQL AB (registered) trademarks.  *Note MySQL AB
  2416. Logos and Trademarks::.
  2417.  
  2418. Using the MySQL Software Under a Commercial License
  2419. ...................................................
  2420.  
  2421. The GPL license is contagious in the sense that when a program is
  2422. linked to a GPL program, all the source code for all the parts of the
  2423. resulting product must also be released under the GPL.  If you do not
  2424. follow this GPL requirement, you break the license terms and forfeit
  2425. your right to use the GPL program altogether.  You also risk damages.
  2426.  
  2427. You need a commercial license under these conditions:
  2428.  
  2429.    * When you link a program with any GPL code from the MySQL software
  2430.      and don't want the resulting product to be licensed under GPL,
  2431.      perhaps because you want to build a commercial product or keep the
  2432.      added non-GPL code closed source for other reasons. When purchasing
  2433.      commercial licenses, you are not using the MySQL software under
  2434.      GPL even though it's the same code.
  2435.  
  2436.    * When you distribute a non-GPL application that works _only_ with
  2437.      the MySQL software and ship it with the MySQL software. This type
  2438.      of solution is considered to be linking even if it's done over a
  2439.      network.
  2440.  
  2441.    * When you distribute copies of the MySQL software without providing
  2442.      the source code as required under the GPL license.
  2443.  
  2444.    * When you want to support the further development of the MySQL
  2445.      database even if you don't formally need a commercial license.
  2446.      Purchasing support directly from MySQL AB is another good way of
  2447.      contributing to the development of the MySQL software, with
  2448.      immediate advantages for you.  *Note Support::.
  2449.  
  2450. Our GPL licensing is supported by an optional license exception that
  2451. enables many Free/Libre and Open Source Software ("FLOSS") applications
  2452. to include the GPL-licensed MySQL client libraries despite the fact
  2453. that not all FLOSS licenses are compatible with the GPL. For details,
  2454. see `http://www.mysql.com/products/licensing/foss-exception.html'.
  2455.  
  2456. If you require a commercial license, you will need one for each
  2457. installation of the MySQL software. This covers any number of CPUs on a
  2458. machine, and there is no artificial limit on the number of clients that
  2459. connect to the server in any way.
  2460.  
  2461. For commercial licenses, please visit our Web site at
  2462. `http://www.mysql.com/products/licensing/'.  For support contracts, see
  2463. `http://www.mysql.com/support/'.  If you have special needs, please
  2464. contact our sales staff via email at <sales@mysql.com>.
  2465.  
  2466. Using the MySQL Software for Free Under GPL
  2467. ...........................................
  2468.  
  2469. You can use the MySQL software for free under the GPL if you adhere to
  2470. the conditions of the GPL.  For additional details about the GPL,
  2471. including answers to common questions, see the generic FAQ from the
  2472. Free Software Foundation at `http://www.fsf.org/licenses/gpl-faq.html'.
  2473.  
  2474. Our GPL licensing is supported by an optional license exception that
  2475. enables many Free/Libre and Open Source Software ("FLOSS") applications
  2476. to include the GPL-licensed MySQL client libraries despite the fact
  2477. that not all FLOSS licenses are compatible with the GPL. For details,
  2478. see `http://www.mysql.com/products/licensing/foss-exception.html'.
  2479.  
  2480. Common uses of the GPL include:
  2481.  
  2482.    * When you distribute both your own application and the MySQL source
  2483.      code under the GPL with your product.
  2484.  
  2485.    * When you distribute the MySQL source code bundled with other
  2486.      programs that are not linked to or dependent on the MySQL system
  2487.      for their functionality even if you sell the distribution
  2488.      commercially.  This is called "mere aggregation" in the GPL
  2489.      license.
  2490.  
  2491.    * When you are not distributing _any_ part of the MySQL system, you
  2492.      can use it for free.
  2493.  
  2494.    * When you are an Internet Service Provider (ISP), offering Web
  2495.      hosting with MySQL servers for your customers.  We encourage
  2496.      people to use ISPs that have MySQL support, because doing so will
  2497.      give them the confidence that their ISP will, in fact, have the
  2498.      resources to solve any problems they may experience with the MySQL
  2499.      installation. Even if an ISP does not have a commercial license
  2500.      for MySQL Server, their customers should at least be given read
  2501.      access to the source of the MySQL installation so that the
  2502.      customers can verify that it is correctly patched.
  2503.  
  2504.    * When you use the MySQL database software in conjunction with a Web
  2505.      server, you do not need a commercial license (so long as it is not
  2506.      a product you distribute). This is true even if you run a
  2507.      commercial Web server that uses MySQL Server, because you are not
  2508.      distributing any part of the MySQL system. However, in this case
  2509.      we would like you to purchase MySQL support because the MySQL
  2510.      software is helping your enterprise.
  2511.  
  2512. If your use of MySQL database software does not require a commercial
  2513. license, we encourage you to purchase support from MySQL AB anyway.
  2514. This way you contribute toward MySQL development and also gain
  2515. immediate advantages for yourself. *Note Support::.
  2516.  
  2517. If you use the MySQL database software in a commercial context such
  2518. that you profit by its use, we ask that you further the development of
  2519. the MySQL software by purchasing some level of support.  We feel that
  2520. if the MySQL database helps your business, it is reasonable to ask that
  2521. you help MySQL AB.  (Otherwise, if you ask us support questions, you
  2522. are not only using for free something into which we've put a lot a
  2523. work, you're asking us to provide free support, too.)
  2524.  
  2525. MySQL AB Logos and Trademarks
  2526. -----------------------------
  2527.  
  2528. Many users of the MySQL database want to display the MySQL AB dolphin
  2529. logo on their Web sites, books, or boxed products. We welcome and
  2530. encourage this, although it should be noted that the word MySQL and the
  2531. MySQL dolphin logo are (registered) trademarks of MySQL AB and may only
  2532. be used as stated in our trademark policy at
  2533. `http://www.mysql.com/company/trademark.html'.
  2534.  
  2535. The Original MySQL Logo
  2536. .......................
  2537.  
  2538. The MySQL dolphin logo was designed by the Finnish advertising agency
  2539. Priority in 2001.  The dolphin was chosen as a suitable symbol for the
  2540. MySQL database management system, which is like a smart, fast, and lean
  2541. animal, effortlessly navigating oceans of data. We also happen to like
  2542. dolphins.
  2543.  
  2544. The original MySQL logo may only be used by representatives of MySQL AB
  2545. and by those having a written agreement allowing them to do so.
  2546.  
  2547. MySQL Logos That May Be Used Without Written Permission
  2548. .......................................................
  2549.  
  2550. We have designed a set of special _Conditional Use_ logos that may be
  2551. downloaded from our Web site at `http://www.mysql.com/press/logos.html'
  2552. and used on third-party Web sites without written permission from MySQL
  2553. AB.  The use of these logos is not entirely unrestricted but, as the
  2554. name implies, subject to our trademark policy that is also available on
  2555. our Web site. You should read through the trademark policy if you plan
  2556. to use them. The requirements are basically as follows:
  2557.  
  2558.    * Use the logo you need as displayed on the `http://www.mysql.com/'
  2559.      site. You may scale it to fit your needs, but may not change
  2560.      colors or design, or alter the graphics in any way.
  2561.  
  2562.    * Make it evident that you, and not MySQL AB, are the creator and
  2563.      owner of the site that displays the MySQL (registered) trademark.
  2564.  
  2565.    * Don't use the trademark in a way that is detrimental to MySQL AB
  2566.      or to the value of MySQL AB trademarks. We reserve the right to
  2567.      revoke the right to use the MySQL AB trademark.
  2568.  
  2569.    * If you use the trademark on a Web site, make it clickable, leading
  2570.      directly to `http://www.mysql.com/'.
  2571.  
  2572.    * If you use the MySQL database under GPL in an application, your
  2573.      application must be Open Source and must be able to connect to a
  2574.      MySQL server.
  2575.  
  2576. Contact us via email at <trademark@mysql.com> to inquire about special
  2577. arrangements to fit your needs.
  2578.  
  2579. When You Need Written Permission to Use MySQL Logos
  2580. ...................................................
  2581.  
  2582. You need written permission from MySQL AB before using MySQL logos in
  2583. the following cases:
  2584.  
  2585.    * When displaying any MySQL AB logo anywhere except on your Web site.
  2586.  
  2587.    * When displaying any MySQL AB logo except the _Conditional Use_
  2588.      logos (mentioned previously) on Web sites or elsewhere.
  2589.  
  2590. Due to legal and commercial reasons, we monitor the use of MySQL
  2591. (registered) trademarks on products, books, and other items.  We
  2592. usually require a fee for displaying MySQL AB logos on commercial
  2593. products, since we think it is reasonable that some of the revenue is
  2594. returned to fund further development of the MySQL database.
  2595.  
  2596. MySQL AB Partnership Logos
  2597. ..........................
  2598.  
  2599. MySQL partnership logos may be used only by companies and persons
  2600. having a written partnership agreement with MySQL AB. Partnerships
  2601. include certification as a MySQL trainer or consultant.  For more
  2602. information, please see *Note Partnering: Business Services Partnering.
  2603.  
  2604. Using the Word MySQL in Printed Text or Presentations
  2605. .....................................................
  2606.  
  2607. MySQL AB welcomes references to the MySQL database, but it should be
  2608. noted that the word MySQL is a registered trademark of MySQL AB.
  2609. Because of this, you must append the "registered trademark" notice
  2610. symbol (`R') to the first or most prominent use of the word MySQL in a
  2611. text and, where appropriate, state that MySQL is a registered trademark
  2612. of MySQL AB. For more information, please refer to our trademark policy
  2613. at `http://www.mysql.com/company/trademark.html'.
  2614.  
  2615. Using the Word MySQL in Company and Product Names
  2616. .................................................
  2617.  
  2618. Use of the word MySQL in company or product names or in Internet domain
  2619. names is not allowed without written permission from MySQL AB.
  2620.  
  2621. MySQL Development Roadmap
  2622. =========================
  2623.  
  2624. This section provides a snapshot of the MySQL development roadmap,
  2625. including major features implemented or planned for MySQL 4.0, 4.1,
  2626. 5.0, and 5.1.  The following sections provide information for each
  2627. release series.
  2628.  
  2629. The production release series is MySQL 4.0, which was declared stable
  2630. for production use as of Version 4.0.12, released in March 2003. This
  2631. means that future 4.0 development will be limited only to making
  2632. bugfixes. For the older MySQL 3.23 series, only critical bugfixes will
  2633. be made.
  2634.  
  2635. Active MySQL development currently is taking place in the MySQL 4.1 and
  2636. 5.0 release series. This means that new features are being added to
  2637. MySQL 4.1 and MySQL 5.0.  4.1 is available in beta status, and 5.0 is
  2638. available in alpha status.
  2639.  
  2640. Before upgrading from one release series to the next, please see the
  2641. notes at *Note Upgrade::.
  2642.  
  2643. Plans for some of the most requested features are summarized in the
  2644. following table.
  2645.  
  2646. *Feature*              *MySQL Series*
  2647. Unions                 4.0
  2648. Subqueries             4.1
  2649. R-trees                4.1 (for `MyISAM' tables)
  2650. Stored procedures      5.0
  2651. Views                  5.0
  2652. Cursors                5.0
  2653. Foreign keys           5.1 (already implemented in 3.23 for
  2654.                        `InnoDB')
  2655. Triggers               5.1
  2656. Full outer join        5.1
  2657. Constraints            5.1
  2658.  
  2659. MySQL 4.0 in a Nutshell
  2660. -----------------------
  2661.  
  2662. Long awaited by our users, MySQL Server 4.0 is available in production
  2663. status.
  2664.  
  2665. MySQL 4.0 is available for download at `http://dev.mysql.com/' and from
  2666. our mirrors. MySQL 4.0 has been tested by a large number of users and
  2667. is in production use at many large sites.
  2668.  
  2669. The major new features of MySQL Server 4.0 are geared toward our
  2670. existing business and community users, enhancing the MySQL database
  2671. software as the solution for mission-critical, heavy-load database
  2672. systems.  Other new features target the users of embedded databases.
  2673.  
  2674. Features Available in MySQL 4.0
  2675. ...............................
  2676.  
  2677. Speed enhancements
  2678.         * MySQL 4.0 has a query cache that can give a huge speed boost
  2679.           to applications with repetitive queries. *Note Query Cache::.
  2680.  
  2681.         * Version 4.0 further increases the speed of MySQL Server in a
  2682.           number of areas, such as bulk `INSERT' statements, searching
  2683.           on packed indexes, full-text searching (using `FULLTEXT'
  2684.           indexes), and `COUNT(DISTINCT)'.
  2685.  
  2686. Embedded MySQL Server introduced
  2687.         * The new Embedded Server library can easily be used to create
  2688.           standalone and embedded applications.  The embedded server
  2689.           provides an alternative to using MySQL in a client/server
  2690.           environment.  *Note Nutshell Embedded MySQL::.
  2691.  
  2692. `InnoDB' storage engine as standard
  2693.         * The `InnoDB' storage engine is offered as a standard feature
  2694.           of the MySQL server. This means full support for ACID
  2695.           transactions, foreign keys with cascading `UPDATE' and
  2696.           `DELETE', and row-level locking are now standard features.
  2697.           *Note `InnoDB': InnoDB.
  2698.  
  2699. New functionality
  2700.         * The enhanced `FULLTEXT' search properties of MySQL Server 4.0
  2701.           enables `FULLTEXT' indexing of large text masses with both
  2702.           binary and natural-language searching logic. You can
  2703.           customize minimal word length and define your own stop word
  2704.           lists in any human language, enabling a new set of
  2705.           applications to be built with MySQL Server.  *Note Fulltext
  2706.           Search::.
  2707.  
  2708. Standards compliance, portability, and migration
  2709.         * Many users will also be happy to learn that MySQL Server now
  2710.           supports the `UNION' statement, a long-awaited standard SQL
  2711.           feature.
  2712.  
  2713.         * MySQL runs natively on the Novell NetWare platform beginning
  2714.           with NetWare 6.0.  *Note NetWare installation::.
  2715.  
  2716.         * Features to simplify migration from other database systems to
  2717.           MySQL Server include `TRUNCATE TABLE' (as in Oracle).
  2718.  
  2719. Internationalization
  2720.         * Our German, Austrian, and Swiss users will note that MySQL
  2721.           4.0 now supports a new character set, `latin1_de', which
  2722.           ensures that the _German sorting order_ sorts words with
  2723.           umlauts in the same order as do German telephone books.
  2724.  
  2725. Usability enhancements
  2726.      In the process of implementing features for new users, we have not
  2727.      forgotten requests from our loyal community of existing users.
  2728.  
  2729.         * Most `mysqld' parameters (startup options) can be set without
  2730.           taking down the server. This is a convenient feature for
  2731.           database administrators (DBAs).  *Note `SET OPTION': SET
  2732.           OPTION.
  2733.  
  2734.         * Multiple-table `DELETE' and `UPDATE' statements have been
  2735.           added.
  2736.  
  2737.         * On Windows, symbolic link handling at the database level is
  2738.           enabled by default.  On Unix, the `MyISAM' storage engine
  2739.           supports symbolic linking at the table level (and not just
  2740.           the database level as before).
  2741.  
  2742.         * `SQL_CALC_FOUND_ROWS' and `FOUND_ROWS()' are new functions
  2743.           that make it possible to find out the number of rows a
  2744.           `SELECT' query that includes a `LIMIT' clause would have
  2745.           returned without that clause.
  2746.  
  2747. The news section of this manual includes a more in-depth list of
  2748. features.  *Note News-4.0.x::.
  2749.  
  2750. The Embedded MySQL Server
  2751. .........................
  2752.  
  2753. The `libmysqld' embedded server library makes MySQL Server suitable for
  2754. a vastly expanded realm of applications. By using this library,
  2755. developers can embed MySQL Server into various applications and
  2756. electronics devices, where the end user has no knowledge of there
  2757. actually being an underlying database. Embedded MySQL Server is ideal
  2758. for use behind the scenes in Internet appliances, public kiosks, turnkey
  2759. hardware/software combination units, high performance Internet servers,
  2760. self-contained databases distributed on CD-ROM, and so on.
  2761.  
  2762. Many users of `libmysqld' will benefit from the MySQL Dual Licensing.
  2763. For those not wishing to be bound by the GPL, the software is also made
  2764. available under a commercial license.  The embedded MySQL library uses
  2765. the same interface as the normal client library, so it is convenient
  2766. and easy to use.  *Note `libmysqld': libmysqld.
  2767.  
  2768. On windows there are two different libraries:
  2769.  
  2770. `libmysqld.lib'        Dynamic library for threaded applications.
  2771. `mysqldemb.lib'        Static library for not threaded
  2772.                        applications.
  2773.  
  2774. MySQL 4.1 in a Nutshell
  2775. -----------------------
  2776.  
  2777. MySQL Server 4.0 laid the foundation for new features implemented in
  2778. MySQL 4.1, such as subqueries and Unicode support, and for the work on
  2779. stored procedures being done in version 5.0.  These features come at
  2780. the top of the wish list of many of our customers.
  2781.  
  2782. With these additions, critics of the MySQL Database Server have to be
  2783. more imaginative than ever in pointing out deficiencies in the MySQL
  2784. database management system. Already well-known for its stability,
  2785. speed, and ease of use, MySQL Server is able to fulfill the requirement
  2786. checklists of very demanding buyers.
  2787.  
  2788. Features Available in MySQL 4.1
  2789. ...............................
  2790.  
  2791. The MySQL 4.1 features listed in this section already are implemented.
  2792. A few other MySQL 4.1 features are still planned; see *Note TODO MySQL
  2793. 4.1::.
  2794.  
  2795. Most new features being coded are or will be available in MySQL 5.0.
  2796. *Note TODO MySQL 5.0::.
  2797.  
  2798. Support for subqueries and derived tables
  2799.         * A "subquery" is a `SELECT' statement nested within another
  2800.           statement.  A "derived table" (an unnamed view) is a subquery
  2801.           in the `FROM' clause of another statement.  *Note
  2802.           Subqueries::.
  2803.  
  2804. Speed enhancements
  2805.         * Faster binary client/server protocol with support for
  2806.           prepared statements and parameter binding.  *Note C API
  2807.           Prepared statements::.
  2808.  
  2809.         * `BTREE' indexing is supported for `HEAP' tables,
  2810.           significantly improving response time for non-exact searches.
  2811.  
  2812. New functionality
  2813.         * `CREATE TABLE TBL_NAME2 LIKE TBL_NAME1' allows you to create,
  2814.           with a single statement, a new table with a structure exactly
  2815.           like that of an existing table.
  2816.  
  2817.         * The `MyISAM' storage engine supports OpenGIS spatial types
  2818.           for storing geographical data.  *Note Spatial extensions in
  2819.           MySQL::.
  2820.  
  2821.         * Replication can be done over SSL connections.
  2822.  
  2823. Standards compliance, portability, and migration
  2824.         * The new client/server protocol adds the ability to pass
  2825.           multiple warnings to the client, rather than only a single
  2826.           result. This makes it much easier to track problems that
  2827.           occur in operations such as bulk data loading.
  2828.  
  2829.         * `SHOW WARNINGS' shows warnings for the last command.  *Note
  2830.           `SHOW WARNINGS': SHOW WARNINGS.
  2831.  
  2832. Internationalization and Localization
  2833.         * To support applications that require the use of local
  2834.           languages, the MySQL software offers extensive Unicode
  2835.           support through the `utf8' and `ucs2' character sets.
  2836.  
  2837.         * Character sets can be defined per column, table, and database.
  2838.           This allows for a high degree of flexibility in application
  2839.           design, particularly for multi-language Web sites.
  2840.  
  2841.         * For documentation for this improved character set support,
  2842.           see *Note Charset::.
  2843.  
  2844.         * Per-connection time zones are supported, allowing individual
  2845.           clients to select their own time zone when necessary.
  2846.  
  2847. Usability enhancements
  2848.         * In response to popular demand, we have added a server-based
  2849.           `HELP' command that can be used to get help information for
  2850.           SQL statements.  The advantage of having this information on
  2851.           the server side is that the information is always applicable
  2852.           to the particular server version that you actually are using.
  2853.           Because this information is available by issuing an SQL
  2854.           statement, any client can be written to access it.  For
  2855.           example, the `help' command of the `mysql' command-line client
  2856.           has been modified to have this capability.
  2857.  
  2858.         * In the new client/server protocol, multiple statements can be
  2859.           issued with a single call.  *Note C API multiple queries::.
  2860.  
  2861.         * The new client/server protocol also supports returning
  2862.           multiple result sets.  This might occur as a result of
  2863.           sending multiple statements, for example.
  2864.  
  2865.         * A new `INSERT ... ON DUPLICATE KEY UPDATE ...' syntax has been
  2866.           implemented. This allows you to `UPDATE' an existing row if
  2867.           the `INSERT' would have caused a duplicate in a `PRIMARY' or
  2868.           `UNIQUE' index.  *Note `INSERT': INSERT.
  2869.  
  2870.         * A new aggregate function, `GROUP_CONCAT()' adds the extremely
  2871.           useful capability of concatenating column values from grouped
  2872.           rows into a single result string.  *Note Group by functions
  2873.           and modifiers::.
  2874.  
  2875. The news section of this manual includes a more in-depth list of
  2876. features.  *Note News-4.1.x::.
  2877.  
  2878. Stepwise Rollout
  2879. ................
  2880.  
  2881. New features are being added to MySQL 4.1. The beta version is already
  2882. available for download. *Note Nutshell Ready for Immediate Use::.
  2883.  
  2884. The set of features being added to version 4.1 is mostly fixed.
  2885. Additional development is already ongoing for version 5.0.  MySQL 4.1
  2886. is going through the steps of _Alpha_ (during which time new features
  2887. might still be added/changed), _Beta_ (when we have feature freeze and
  2888. only bug corrections will be done), and _Gamma_ (indicating that a
  2889. production release is just weeks ahead).  At the end of this process,
  2890. MySQL 4.1 will become the new production release.
  2891.  
  2892. Ready for Immediate Development Use
  2893. ...................................
  2894.  
  2895. MySQL 4.1 is currently in the beta stage, and binaries are available
  2896. for download at `http://dev.mysql.com/downloads/mysql/4.1.html'.  All
  2897. binary releases pass our extensive test suite without any errors on the
  2898. platforms on which we test.  *Note News-4.1.x::.
  2899.  
  2900. For those wishing to use the most recent development source for MySQL
  2901. 4.1, we make our 4.1 BitKeeper repository publicly available.  *Note
  2902. Installing source tree::.
  2903.  
  2904. MySQL 5.0: The Next Development Release
  2905. ---------------------------------------
  2906.  
  2907. New development for MySQL is focused on the 5.0 release, featuring
  2908. stored procedures and other new features.  *Note TODO MySQL 5.0::.
  2909.  
  2910. For those wishing to take a look at the bleeding edge of MySQL
  2911. development, we make our BitKeeper repository for MySQL version 5.0
  2912. publicly available.  *Note Installing source tree::.  As of December
  2913. 2003, binary builds of version 5.0 are also available.
  2914.  
  2915. MySQL and the Future (the TODO)
  2916. ===============================
  2917.  
  2918. This section summarizes the features that we plan to implement in MySQL
  2919. Server. The items are ordered by release series. Within a list, items
  2920. are shown in approximately the order they will be done.
  2921.  
  2922. *Note*: If you are an enterprise-level user with an urgent need for a
  2923. particular feature, please contact <sales@mysql.com> to discuss
  2924. sponsoring options. Targeted financing by sponsor companies allows us
  2925. to allocate additional resources for specific purposes.  One example of
  2926. a feature sponsored in the past is replication.
  2927.  
  2928. New Features Planned for 4.1
  2929. ----------------------------
  2930.  
  2931. The following features are not yet implemented in MySQL 4.1, but are
  2932. planned for implementation as MySQL 4.1 moves into its beta phase.  For
  2933. a list what is already done in MySQL 4.1, see *Note Nutshell 4.1
  2934. features::.
  2935.  
  2936.    * Stable OpenSSL support (MySQL 4.0 supports rudimentary, not 100%
  2937.      tested, support for OpenSSL).
  2938.  
  2939.    * More testing of prepared statements.
  2940.  
  2941.    * More testing of multiple character sets for one table.
  2942.  
  2943. New Features Planned for 5.0
  2944. ----------------------------
  2945.  
  2946. The following features are planned for inclusion into MySQL 5.0.  Some
  2947. of the features such as stored procedures are complete and are included
  2948. in MySQL 5.0 alpha, which is available now.  Others such as cursors are
  2949. only partially available. Expect these and other features to mature and
  2950. be fully supported in upcoming releases.
  2951.  
  2952. Note that because we have many developers that are working on different
  2953. projects, there will also be many additional features. There is also a
  2954. small chance that some of these features will be added to MySQL 4.1.
  2955. For a list what is already done in MySQL 4.1, see *Note Nutshell 4.1
  2956. features::.
  2957.  
  2958. For those wishing to take a look at the bleeding edge of MySQL
  2959. development, we make our BitKeeper repository for MySQL version 5.0
  2960. publicly available.  *Note Installing source tree::.  As of December
  2961. 2003, binary builds of version 5.0 are also available.
  2962.  
  2963. Views
  2964.         * Views, implemented in stepwise fashion up to full
  2965.           functionality.  *Note ANSI diff Views::.
  2966.  
  2967. Stored Procedures
  2968.         * Stored procedures currently are implemented, based on the
  2969.           SQL:2003 standard.  *Note Stored Procedures::.
  2970.  
  2971.  
  2972. New functionality
  2973.         * Elementary cursor support.  *Note Cursors::.
  2974.  
  2975.         * The ability to specify explicitly for `MyISAM' tables that an
  2976.           index should be created as an `RTREE' index.  (In MySQL 4.1,
  2977.           `RTREE' indexes are used internally for geometrical data that
  2978.           use GIS data types, but cannot be created on request.)
  2979.  
  2980.         * Dynamic length rows for `MEMORY' tables.
  2981.  
  2982. Standards compliance, portability and migration
  2983.         * Support for Data Dictionary / `INFORMATION_SCHEMA'.
  2984.  
  2985.         * Add true `VARCHAR' support (column lengths longer than 255,
  2986.           and no stripping of trailing whitespace).  There is already
  2987.           support for this in the `MyISAM' storage engine, but it is
  2988.           not yet available at the user level.
  2989.  
  2990. Speed enhancements
  2991.         * `SHOW COLUMNS FROM TBL_NAME' (used by the `mysql' client to
  2992.           allow expansions of column names) should not open the table,
  2993.           only the definition file. This will require less memory and
  2994.           be much faster.
  2995.  
  2996.         * Allow `DELETE' on `MyISAM' tables to use the record cache.
  2997.           To do this, we need to update the threads record cache when
  2998.           we update the `.MYD' file.
  2999.  
  3000.         * Better support for `MEMORY' tables:
  3001.              * Dynamic length rows.
  3002.  
  3003.              * Faster row handling (less copying).
  3004.  
  3005. Usability enhancements
  3006.         * Resolving the issue of `RENAME TABLE' on a table used in an
  3007.           active `MERGE' table possibly corrupting the table.
  3008.  
  3009. The news section of this manual includes a more in-depth list of
  3010. features.  *Note News-5.0.x::.
  3011.  
  3012. New Features Planned for 5.1
  3013. ----------------------------
  3014.  
  3015. New functionality
  3016.         * `FOREIGN KEY' support for all table types, not just `InnoDB'.
  3017.  
  3018.         * Column-level constraints.  *Note Constraints::.
  3019.  
  3020.         * Online backup with very low performance penalty.  The online
  3021.           backup will make it easy to add a new replication slave
  3022.           without taking down the master.
  3023.  
  3024. Speed enhancements
  3025.         * New text based table definition file format (`.frm' files)
  3026.           and a table cache for table definitions.  This will enable us
  3027.           to do faster queries of table structures and do more
  3028.           efficient foreign key support.
  3029.  
  3030.         * Optimize the `BIT' type to take one bit. (`BIT' now takes one
  3031.           byte; it is treated as a synonym for `TINYINT'.)
  3032.  
  3033. Usability enhancements
  3034.         * Add options to the client/server protocol to get progress
  3035.           notes for long running commands.
  3036.  
  3037.         * Implement `RENAME DATABASE'. To make this safe for all
  3038.           storage engines, it should work as follows:
  3039.             1. Create the new database.
  3040.  
  3041.             2. For every table, do a rename of the table to another
  3042.                database, as we do with the `RENAME' command.
  3043.  
  3044.             3. Drop the old database.
  3045.  
  3046.         * New internal file interface change.  This will make all file
  3047.           handling much more general and make it easier to add
  3048.           extensions like RAID.
  3049.  
  3050. New Features Planned for the Near Future
  3051. ----------------------------------------
  3052.  
  3053. New functionality
  3054.         * Oracle-like `CONNECT BY PRIOR' to search tree-like
  3055.           (hierarchical) structures.
  3056.  
  3057.         * Add all missing standard SQL and ODBC 3.0 types.
  3058.  
  3059.         * Add `SUM(DISTINCT)'.
  3060.  
  3061.         * `INSERT SQL_CONCURRENT' and `mysqld --concurrent-insert' to do
  3062.           a concurrent insert at the end of a table if the table is
  3063.           read-locked.
  3064.  
  3065.         * Allow variables to be updated in `UPDATE' statements. For
  3066.           example: `UPDATE foo SET @a:=a+b,a=@a, b=@a+c'.
  3067.  
  3068.         * Change when user variables are updated so that you can use
  3069.           them with `GROUP BY', as in the following statement: `SELECT
  3070.           id, @a:=COUNT(*), SUM(SUM_COL)/@a FROM TBL_NAME GROUP BY id'.
  3071.  
  3072.         * Add an `IMAGE' option to `LOAD DATA INFILE' to not update
  3073.           `TIMESTAMP' and `AUTO_INCREMENT' columns.
  3074.  
  3075.         * Add `LOAD DATA INFILE ... UPDATE' syntax that works like this:
  3076.              * For tables with primary keys, if an input record
  3077.                contains a primary key value, existing rows matching
  3078.                that primary key value are updated from the remainder of
  3079.                the input columns. However, columns corresponding to
  3080.                columns that are _missing_ from the input record are not
  3081.                touched.
  3082.  
  3083.              * For tables with primary keys, if an input record does
  3084.                not contain the primary key value or is missing some
  3085.                part of the key, the record is treated as `LOAD DATA
  3086.                INFILE ... REPLACE INTO'.
  3087.  
  3088.         * Make `LOAD DATA INFILE' understand syntax like this:
  3089.                LOAD DATA INFILE 'FILE_NAME.txt' INTO TABLE TBL_NAME
  3090.                     TEXT_FIELDS (text_col1, text_col2, text_col3)
  3091.                     SET table_col1=CONCAT(text_col1, text_col2),
  3092.                         table_col3=23
  3093.                     IGNORE text_col3
  3094.           This can be used to skip over extra columns in the text file,
  3095.           or update columns based on expressions of the read data.
  3096.  
  3097.         * New functions for working with `SET' type columns:
  3098.              * `ADD_TO_SET(VALUE,SET)'
  3099.  
  3100.              * `REMOVE_FROM_SET(VALUE,SET)'
  3101.  
  3102.         * If you abort `mysql' in the middle of a query, you should open
  3103.           another connection and kill the old running query.
  3104.           Alternatively, an attempt should be made to detect this in
  3105.           the server.
  3106.  
  3107.         * Add a storage engine interface for table information so that
  3108.           you can use it as a system table. This would be a bit slow if
  3109.           you requested information about all tables, but very
  3110.           flexible.  `SHOW INFO FROM TBL_NAME' for basic table
  3111.           information should be implemented.
  3112.  
  3113.         * Allow `SELECT a FROM TBL_NAME1 LEFT JOIN TBL_NAME2 USING
  3114.           (a)'; in this case `a' is assumed to come from TBL_NAME1.
  3115.  
  3116.         * `DELETE' and `REPLACE' options to the `UPDATE' statement
  3117.           (this will delete rows when a duplicate-key error occurs
  3118.           while updating).
  3119.  
  3120.         * Change the format of `DATETIME' to store fractions of seconds.
  3121.  
  3122.         * Make it possible to use the new GNU `regexp' library instead
  3123.           of the current one (the new library should be much faster
  3124.           than the current one).
  3125.  
  3126. Standards compliance, portability and migration
  3127.         * Don't add automatic `DEFAULT' values to columns.  Produce an
  3128.           error for any `INSERT' statement that is missing a value for
  3129.           a column that has no `DEFAULT'.
  3130.  
  3131.         * Add `ANY()', `EVERY()', and `SOME()' group functions. In
  3132.           standard SQL, these work only on boolean columns, but we can
  3133.           extend these to work on any columns or expressions by
  3134.           treating a value of zero as FALSE and non-zero values as TRUE.
  3135.  
  3136.         * Fix the type of `MAX(column)' to be the same as the column
  3137.           type:
  3138.                mysql> CREATE TABLE t1 (a DATE);
  3139.                mysql> INSERT INTO t1 VALUES (NOW());
  3140.                mysql> CREATE TABLE t2 SELECT MAX(a) FROM t1;
  3141.                mysql> SHOW COLUMNS FROM t2;
  3142.  
  3143. Speed enhancements
  3144.         * Don't allow more than a defined number of threads to run
  3145.           `MyISAM' recovery at the same time.
  3146.  
  3147.         * Change `INSERT INTO ... SELECT' to optionally use concurrent
  3148.           inserts.
  3149.  
  3150.         * Add an option to periodically flush key pages for tables with
  3151.           delayed keys if they haven't been used in a while.
  3152.  
  3153.         * Allow join on key parts (optimization issue).
  3154.  
  3155.         * Add a log file analyzer that can extract information about
  3156.           which tables are hit most often, how often multiple-table
  3157.           joins are executed, and so on. This should help users
  3158.           identify areas of table design that could be optimized to
  3159.           execute much more efficient queries.
  3160.  
  3161. Usability enhancements
  3162.         * Return the original column types when doing `SELECT
  3163.           MIN(column) ... GROUP BY'.
  3164.  
  3165.         * Make it possible to specify `long_query_time' with a
  3166.           granularity in microseconds.
  3167.  
  3168.         * Link the `myisampack' code into the server so that it can
  3169.           perform `PACK' or `COMPRESS' operations.
  3170.  
  3171.         * Add a temporary key buffer cache during
  3172.           `INSERT/DELETE/UPDATE' so that we can gracefully recover if
  3173.           the index file gets full.
  3174.  
  3175.         * If you perform an `ALTER TABLE' on a table that is symlinked
  3176.           to another disk, create temporary tables on that disk.
  3177.  
  3178.         * Implement a `DATE/DATETIME' type that handles time zone
  3179.           information properly, to make dealing with dates in different
  3180.           time zones easier.
  3181.  
  3182.         * Fix `configure' so that all libraries (like `MyISAM') can be
  3183.           compiled without threads.
  3184.  
  3185.         * Allow user variables as `LIMIT' arguments; for example,
  3186.           `LIMIT @a,@b'.
  3187.  
  3188.         * Automatic output from `mysql' to a Web browser.
  3189.  
  3190.         * `LOCK DATABASES' (with various options).
  3191.  
  3192.         * Many more variables for `SHOW STATUS'.  Record reads and
  3193.           updates.  Selects on a single table and selects with joins.
  3194.           Mean number of tables in selects. Number of `ORDER BY' and
  3195.           `GROUP BY' queries.
  3196.  
  3197.         * `mysqladmin copy database new-database'; this requires a
  3198.           `COPY' operation to be added to `mysqld'.
  3199.  
  3200.         * Processlist output should indicate the number of
  3201.           queries/threads.
  3202.  
  3203.         * `SHOW HOSTS' for printing information about the hostname
  3204.           cache.
  3205.  
  3206.         * Change table names from empty strings to `NULL' for
  3207.           calculated columns.
  3208.  
  3209.         * Don't use `Item_copy_string' on numerical values to avoid
  3210.           number-to-string-to-number conversion in case of `SELECT
  3211.           COUNT(*)*(id+0) FROM TBL_NAME GROUP BY id'.
  3212.  
  3213.         * Change so that `ALTER TABLE' doesn't abort clients that
  3214.           execute `INSERT DELAYED'.
  3215.  
  3216.         * Fix so that when columns are referenced in an `UPDATE' clause,
  3217.           they contain the old values from before the update started.
  3218.  
  3219. New operating systems
  3220.         * Port the MySQL clients to LynxOS.
  3221.  
  3222. New Features Planned for the Mid-Term Future
  3223. --------------------------------------------
  3224.  
  3225.    * Implement function:
  3226.      `get_changed_tables(timeout,table1,table2,...)'.
  3227.  
  3228.    * Change reading through tables to use `mmap()' when possible. Now
  3229.      only compressed tables use `mmap()'.
  3230.  
  3231.    * Make the automatic timestamp code nicer.  Add timestamps to the
  3232.      update log with `SET TIMESTAMP=val;'.
  3233.  
  3234.    * Use read/write mutex in some places to get more speed.
  3235.  
  3236.    * Automatically close some tables if a table, temporary table, or
  3237.      temporary file gets error 23 (too many open files).
  3238.  
  3239.    * Better constant propagation. When an occurrence of COL_NAME=N is
  3240.      found in an expression, for some constant `n', replace other
  3241.      occurrences of COL_NAME within the expression with `n'.
  3242.      Currently, this is done only for some simple cases.
  3243.  
  3244.    * Change all const expressions with calculated expressions if
  3245.      possible.
  3246.  
  3247.    * Optimize KEY = EXPR comparisons. At the moment, only KEY = COLUMN
  3248.      or KEY = CONSTANT comparisons are optimized.
  3249.  
  3250.    * Join some of the copy functions for nicer code.
  3251.  
  3252.    * Change `sql_yacc.yy' to an inline parser to reduce its size and get
  3253.      better error messages.
  3254.  
  3255.    * Change the parser to use only one rule per different number of
  3256.      arguments in function.
  3257.  
  3258.    * Use of full calculation names in the order part (for Access97).
  3259.  
  3260.    * `MINUS', `INTERSECT', and `FULL OUTER JOIN'.  (Currently `UNION'
  3261.      and `LEFT|RIGHT OUTER JOIN' are supported.)
  3262.  
  3263.    * Allow `SQL_OPTION MAX_SELECT_TIME=val', for placing a time limit
  3264.      on a query.
  3265.  
  3266.    * Allow updates to be logged to a database.
  3267.  
  3268.    * Enhance `LIMIT' to allow retrieval of data from the end of a
  3269.      result set.
  3270.  
  3271.    * Alarm around client connect/read/write functions.
  3272.  
  3273.    * Please note the changes to `mysqld_safe': According to FSSTND
  3274.      (which Debian tries to follow), PID files should go into
  3275.      `/var/run/<progname>.pid' and log files into `/var/log'. It would
  3276.      be nice if you could put the "DATADIR" in the first declaration of
  3277.      "pidfile" and "log" so that the placement of these files can be
  3278.      changed with a single statement.
  3279.  
  3280.    * Allow a client to request logging.
  3281.  
  3282.    * Allow the `LOAD DATA INFILE' statement to read files that have
  3283.      been compressed with `gzip'.
  3284.  
  3285.    * Fix sorting and grouping of `BLOB' columns (partly solved now).
  3286.  
  3287.    * Change to use semaphores when counting threads.  One should first
  3288.      implement a semaphore library for MIT-pthreads.
  3289.  
  3290.    * Add full support for `JOIN' with parentheses.
  3291.  
  3292.    * As an alternative to the one-thread-per-connection model, manage a
  3293.      pool of threads to handle queries.
  3294.  
  3295.    * Allow `GET_LOCK()' to obtain more than one lock.  When doing this,
  3296.      it is also necessary to handle the possible deadlocks this change
  3297.      will introduce.
  3298.  
  3299. New Features We Don't Plan to Implement
  3300. ---------------------------------------
  3301.  
  3302. We aim toward full compliance with ANSI/ISO SQL. There are no features
  3303. we plan not to implement.
  3304.  
  3305. MySQL Information Sources
  3306. =========================
  3307.  
  3308. MySQL Mailing Lists
  3309. -------------------
  3310.  
  3311. This section introduces the MySQL mailing lists and provides guidelines
  3312. as to how the lists should be used. When you subscribe to a mailing
  3313. list, you will receive all postings to the list as email messages. You
  3314. can also send your own questions and answers to the list.
  3315.  
  3316. The MySQL Mailing Lists
  3317. .......................
  3318.  
  3319. To subscribe to or unsubscribe from any of the mailing lists described
  3320. in this section, visit `http://lists.mysql.com/'.  Please _do not_ send
  3321. messages about subscribing or unsubscribing to any of the mailing
  3322. lists, because such messages are distributed automatically to thousands
  3323. of other users.
  3324.  
  3325. Your local site may have many subscribers to a MySQL mailing list.  If
  3326. so, the site may have a local mailing list, so that messages sent from
  3327. `lists.mysql.com' to your site are propagated to the local list.  In
  3328. such cases, please contact your system administrator to be added to or
  3329. dropped from the local MySQL list.
  3330.  
  3331. If you wish to have traffic for a mailing list go to a separate mailbox
  3332. in your mail program, set up a filter based on the message headers.
  3333. You can use either the `List-ID:' or `Delivered-To:' headers to identify
  3334. list messages.
  3335.  
  3336. The MySQL mailing lists are as follows:
  3337.  
  3338. `announce'
  3339.      This list is for announcements of new versions of MySQL and related
  3340.      programs.  This is a low-volume list to which all MySQL users
  3341.      should subscribe.
  3342.  
  3343. `mysql'
  3344.      This is the main list for general MySQL discussion.  Please note
  3345.      that some topics are better discussed on the more-specialized
  3346.      lists.  If you post to the wrong list, you may not get an answer.
  3347.  
  3348. `mysql-digest'
  3349.      This is the `mysql' list in digest form.  Subscribing to this list
  3350.      means you will get all list messages, sent as one large mail
  3351.      message once a day.
  3352.  
  3353. `bugs'
  3354.      This list will be of interest to you if you want to stay informed
  3355.      about issues reported since the last release of MySQL or if you
  3356.      want to be actively involved in the process of bug hunting and
  3357.      fixing.  *Note Bug reports::.
  3358.  
  3359. `bugs-digest'
  3360.      This is the `bugs' list in digest form.
  3361.  
  3362. `internals'
  3363.      This list is for people who work on the MySQL code.  This is also
  3364.      the forum for discussions on MySQL development and for posting
  3365.      patches.
  3366.  
  3367. `internals-digest'
  3368.      This is the `internals' list in digest form.
  3369.  
  3370. `mysqldoc'
  3371.      This list is for people who work on the MySQL documentation:
  3372.      people from MySQL AB, translators, and other community members.
  3373.  
  3374. `mysqldoc-digest'
  3375.      This is the `mysqldoc' list in digest form.
  3376.  
  3377. `benchmarks'
  3378.      This list is for anyone interested in performance issues.
  3379.      Discussions concentrate on database performance (not limited to
  3380.      MySQL), but also include broader categories such as performance of
  3381.      the kernel, filesystem, disk system, and so on.
  3382.  
  3383. `benchmarks-digest'
  3384.      This is the `benchmarks' list in digest form.
  3385.  
  3386. `packagers'
  3387.      This list is for discussions on packaging and distributing MySQL.
  3388.      This is the forum used by distribution maintainers to exchange
  3389.      ideas on packaging MySQL and on ensuring that MySQL looks and
  3390.      feels as similar as possible on all supported platforms and
  3391.      operating systems.
  3392.  
  3393. `packagers-digest'
  3394.      This is the `packagers' list in digest form.
  3395.  
  3396. `java'
  3397.      This list is for discussions about the MySQL server and Java. It
  3398.      is mostly used to discuss JDBC drivers, including MySQL
  3399.      Connector/J.
  3400.  
  3401. `java-digest'
  3402.      This is the `java' list in digest form.
  3403.  
  3404. `win32'
  3405.      This list is for all topics concerning the MySQL software on
  3406.      Microsoft operating systems, such as Windows 9x, Me, NT, 2000, and
  3407.      XP.
  3408.  
  3409. `win32-digest'
  3410.      This is the `win32' list in digest form.
  3411.  
  3412. `myodbc'
  3413.      This list is for all topics concerning connecting to the MySQL
  3414.      server with ODBC.
  3415.  
  3416. `myodbc-digest'
  3417.      This is the `myodbc' list in digest form.
  3418.  
  3419. `gui-tools'
  3420.      This list is for all topics concerning MySQL GUI tools, including
  3421.      `MySQL Administrator' and the `MySQL Control Center' graphical
  3422.      client.
  3423.  
  3424. `gui-tools-digest'
  3425.      This is the `gui-tools' list in digest form.
  3426.  
  3427. `cluster'
  3428.      This list is for discussion of MYSQL Cluster.
  3429.  
  3430. `cluster-digest'
  3431.      This is the `cluster' list in digest form.
  3432.  
  3433. `plusplus'
  3434.      This list is for all topics concerning programming with the C++
  3435.      API for MySQL.
  3436.  
  3437. `plusplus-digest'
  3438.      This is the `plusplus' list in digest form.
  3439.  
  3440. `msql-mysql-modules'
  3441.      This list is for all topics concerning the Perl support for MySQL
  3442.      with `msql-mysql-modules', which is now named `DBD::mysql'.
  3443.  
  3444. `msql-mysql-modules-digest'
  3445.      This is the `msql-mysql-modules' list in digest form.
  3446.  
  3447. If you're unable to get an answer to your questions from a MySQL mailing
  3448. list, one option is to purchase support from MySQL AB. This will put you
  3449. in direct contact with MySQL developers. *Note Support::.
  3450.  
  3451. The following table shows some MySQL mailing lists in languages other
  3452. than English.  These lists are not operated by MySQL AB.
  3453.  
  3454. `<mysql-france-subscribe@yahoogroups.com>'
  3455.      A French mailing list.
  3456.  
  3457. `<list@tinc.net>'
  3458.      A Korean mailing list.  Email `subscribe mysql your@email.address'
  3459.      to this list.
  3460.  
  3461. `<mysql-de-request@lists.4t2.com>'
  3462.      A German mailing list.  Email `subscribe mysql-de
  3463.      your@email.address' to this list.  You can find information about
  3464.      this mailing list at `http://www.4t2.com/mysql/'.
  3465.  
  3466. `<mysql-br-request@listas.linkway.com.br>'
  3467.      A Portuguese mailing list.  Email `subscribe mysql-br
  3468.      your@email.address' to this list.
  3469.  
  3470. `<mysql-alta@elistas.net>'
  3471.      A Spanish mailing list.  Email `subscribe mysql
  3472.      your@email.address' to this list.
  3473.  
  3474. Asking Questions or Reporting Bugs
  3475. ..................................
  3476.  
  3477. Before posting a bug report or question, please do the following:
  3478.  
  3479.    * Start by searching the MySQL online manual at
  3480.      `http://dev.mysql.com/doc/'.  We try to keep the manual up to date
  3481.      by updating it frequently with solutions to newly found problems.
  3482.      The change history (`http://dev.mysql.com/doc/mysql/en/News.html')
  3483.      can be particularly useful since it is quite possible that a newer
  3484.      version already contains a solution to your problem.
  3485.  
  3486.    * Search in the bugs database at `http://bugs.mysql.com/' to see
  3487.      whether the bug has already been reported and fixed.
  3488.  
  3489.    * Search the MySQL mailing list archives at
  3490.      `http://lists.mysql.com/'.
  3491.  
  3492.    * You can also use `http://www.mysql.com/search/' to search all the
  3493.      Web pages (including the manual) that are located at the MySQL AB
  3494.      Web site.
  3495.  
  3496. If you can't find an answer in the manual or the archives, check with
  3497. your local MySQL expert.  If you still can't find an answer to your
  3498. question, please follow the guidelines on sending mail to a MySQL
  3499. mailing list, outlined in the next section, before contacting us.
  3500.  
  3501. How to Report Bugs or Problems
  3502. ..............................
  3503.  
  3504. The normal place to report bugs is `http://bugs.mysql.com/', which is
  3505. the address for our bugs database.  This database is public, and can be
  3506. browsed and searched by anyone.  If you log in to the system, you will
  3507. also be able to enter new reports.
  3508.  
  3509. Writing a good bug report takes patience, but doing it right the first
  3510. time saves time both for us and for yourself.  A good bug report,
  3511. containing a full test case for the bug, makes it very likely that we
  3512. will fix the bug in the next release.  This section will help you write
  3513. your report correctly so that you don't waste your time doing things
  3514. that may not help us much or at all.
  3515.  
  3516. We encourage everyone to use the `mysqlbug' script to generate a bug
  3517. report (or a report about any problem).  `mysqlbug' can be found in the
  3518. `scripts' directory (source distribution) and in the `bin' directory
  3519. under your MySQL installation directory (binary distribution).  If you
  3520. are unable to use `mysqlbug' (for example, if you are running on
  3521. Windows), it is still vital that you include all the necessary
  3522. information noted in this section (most importantly, a description of
  3523. the operating system and the MySQL version).
  3524.  
  3525. The `mysqlbug' script helps you generate a report by determining much
  3526. of the following information automatically, but if something important
  3527. is missing, please include it with your message.  Please read this
  3528. section carefully and make sure that all the information described here
  3529. is included in your report.
  3530.  
  3531. Preferably, you should test the problem using the latest production or
  3532. development version of MySQL Server before posting.  Anyone should be
  3533. able to repeat the bug by just using `mysql test < script_file' on the
  3534. included test case or by running the shell or Perl script that is
  3535. included in the bug report.
  3536.  
  3537. All bugs posted in the bugs database at `http://bugs.mysql.com/' will
  3538. be corrected or documented in the next MySQL release. If only minor
  3539. code changes are needed to correct a problem, we may also post a patch
  3540. that fixes the problem.
  3541.  
  3542. If you have found a sensitive security bug in MySQL, you can send email
  3543. to <security@mysql.com>.
  3544.  
  3545. If you have a repeatable bug report, please report it to the bugs
  3546. database at `http://bugs.mysql.com/'.  Note that even in this case it's
  3547. good to run the `mysqlbug' script first to find information about your
  3548. system.  Any bug that we are able to repeat has a high chance of being
  3549. fixed in the next MySQL release.
  3550.  
  3551. To report other problems, you can use one of the MySQL mailing lists.
  3552.  
  3553. Remember that it is possible for us to respond to a message containing
  3554. too much information, but not to one containing too little.  People
  3555. often omit facts because they think they know the cause of a problem
  3556. and assume that some details don't matter.  A good principle is this:
  3557. If you are in doubt about stating something, state it.  It is faster
  3558. and less troublesome to write a couple more lines in your report than
  3559. to wait longer for the answer if we must ask you to provide information
  3560. that was missing from the initial report.
  3561.  
  3562. The most common errors made in bug reports are (a) not including the
  3563. version number of the MySQL distribution used, and (b) not fully
  3564. describing the platform on which the MySQL server is installed
  3565. (including the platform type and version number).  This is highly
  3566. relevant information, and in 99 cases out of 100, the bug report is
  3567. useless without it.  Very often we get questions like, "Why doesn't
  3568. this work for me?" Then we find that the feature requested wasn't
  3569. implemented in that MySQL version, or that a bug described in a report
  3570. has already been fixed in newer MySQL versions.  Sometimes the error is
  3571. platform-dependent; in such cases, it is next to impossible for us to
  3572. fix anything without knowing the operating system and the version
  3573. number of the platform.
  3574.  
  3575. If you compiled MySQL from source, remember also to provide information
  3576. about your compiler, if it is related to the problem.  Often people
  3577. find bugs in compilers and think the problem is MySQL-related.  Most
  3578. compilers are under development all the time and become better version
  3579. by version.  To determine whether your problem depends on your
  3580. compiler, we need to know what compiler you use.  Note that every
  3581. compiling problem should be regarded as a bug and reported accordingly.
  3582.  
  3583. It is most helpful when a good description of the problem is included
  3584. in the bug report.  That is, give a good example of everything you did
  3585. that led to the problem and describe, in exact detail, the problem
  3586. itself.  The best reports are those that include a full example showing
  3587. how to reproduce the bug or problem.  *Note Reproduceable test case::.
  3588.  
  3589. If a program produces an error message, it is very important to include
  3590. the message in your report.  If we try to search for something from the
  3591. archives using programs, it is better that the error message reported
  3592. exactly matches the one that the program produces.  (Even the
  3593. lettercase should be observed.)  You should never try to reproduce from
  3594. memory what the error message was; instead, copy and paste the entire
  3595. message into your report.
  3596.  
  3597. If you have a problem with Connector/ODBC (MyODBC), please try to
  3598. generate a MyODBC trace file and send it with your report.  *Note
  3599. MyODBC bug report::.
  3600.  
  3601. Please remember that many of the people who will read your report will
  3602. do so using an 80-column display.  When generating reports or examples
  3603. using the `mysql' command-line tool, you should therefore use the
  3604. `--vertical' option (or the `\G' statement terminator) for output that
  3605. would exceed the available width for such a display (for example, with
  3606. the `EXPLAIN SELECT' statement; see the example later in this section).
  3607.  
  3608. Please include the following information in your report:
  3609.  
  3610.    * The version number of the MySQL distribution you are using (for
  3611.      example, MySQL 4.0.12). You can find out which version you are
  3612.      running by executing `mysqladmin version'.  The `mysqladmin'
  3613.      program can be found in the `bin' directory under your MySQL
  3614.      installation directory.
  3615.  
  3616.    * The manufacturer and model of the machine on which you experience
  3617.      the problem.
  3618.  
  3619.    * The operating system name and version.  If you work with Windows,
  3620.      you can usually get the name and version number by double-clicking
  3621.      your My Computer icon and pulling down the "Help/About Windows"
  3622.      menu.  For most Unix-like operating systems, you can get this
  3623.      information by executing the command `uname -a'.
  3624.  
  3625.    * Sometimes the amount of memory (real and virtual) is relevant. If
  3626.      in doubt, include these values.
  3627.  
  3628.    * If you are using a source distribution of the MySQL software, the
  3629.      name and version number of the compiler used are needed.  If you
  3630.      have a binary distribution, the distribution name is needed.
  3631.  
  3632.    * If the problem occurs during compilation, include the exact error
  3633.      messages and also a few lines of context around the offending code
  3634.      in the file where the error occurs.
  3635.  
  3636.    * If `mysqld' died, you should also report the query that crashed
  3637.      `mysqld'.  You can usually find this out by running `mysqld' with
  3638.      query logging enabled, and then looking in the log after `mysqld'
  3639.      crashes *Note Using log files::.
  3640.  
  3641.    * If a database table is related to the problem, include the output
  3642.      from `mysqldump --no-data DB_NAME TBL_NAME'.  This is very easy to
  3643.      do and is a powerful way to get information about any table in a
  3644.      database.  The information will help us create a situation
  3645.      matching the one you have.
  3646.  
  3647.    * For speed-related bugs or problems with `SELECT' statements, you
  3648.      should always include the output of `EXPLAIN SELECT ...', and at
  3649.      least the number of rows that the `SELECT' statement produces.  You
  3650.      should also include the output from `SHOW CREATE TABLE TBL_NAME'
  3651.      for each involved table. The more information you give about your
  3652.      situation, the more likely it is that someone can help you.
  3653.  
  3654.      The following is an example of a very good bug report. It should
  3655.      be posted with the `mysqlbug' script.  The example uses the `mysql'
  3656.      command-line tool. Note the use of the `\G' statement terminator
  3657.      for statements whose output width would otherwise exceed that of
  3658.      an 80-column display device.
  3659.  
  3660.           mysql> SHOW VARIABLES;
  3661.           mysql> SHOW COLUMNS FROM ...\G
  3662.                  <output from SHOW COLUMNS>
  3663.           mysql> EXPLAIN SELECT ...\G
  3664.                  <output from EXPLAIN>
  3665.           mysql> FLUSH STATUS;
  3666.           mysql> SELECT ...;
  3667.                  <A short version of the output from SELECT,
  3668.                  including the time taken to run the query>
  3669.           mysql> SHOW STATUS;
  3670.                  <output from SHOW STATUS>
  3671.  
  3672.    * If a bug or problem occurs while running `mysqld', try to provide
  3673.      an input script that will reproduce the anomaly.  This script
  3674.      should include any necessary source files.  The more closely the
  3675.      script can reproduce your situation, the better.  If you can make
  3676.      a reproducible test case, you should post it on
  3677.      `http://bugs.mysql.com/' for high-priority treatment.
  3678.  
  3679.      If you can't provide a script, you should at least include the
  3680.      output from `mysqladmin variables extended-status processlist' in
  3681.      your mail to provide some information on how your system is
  3682.      performing.
  3683.  
  3684.    * If you can't produce a test case with only a few rows, or if the
  3685.      test table is too big to be mailed to the mailing list (more than
  3686.      10 rows), you should dump your tables using `mysqldump' and create
  3687.      a `README' file that describes your problem.
  3688.  
  3689.      Create a compressed archive of your files using `tar' and `gzip'
  3690.      or `zip', and use FTP to transfer the archive to
  3691.      `ftp://ftp.mysql.com/pub/mysql/upload/'.  Then enter the problem
  3692.      into our bugs database at `http://bugs.mysql.com/'.
  3693.  
  3694.    * If you think that the MySQL server produces a strange result from
  3695.      a query, include not only the result, but also your opinion of
  3696.      what the result should be, and an account describing the basis for
  3697.      your opinion.
  3698.  
  3699.    * When giving an example of the problem, it's better to use the
  3700.      variable names, table names, and so on that exist in your actual
  3701.      situation than to come up with new names.  The problem could be
  3702.      related to the name of a variable or table.  These cases are rare,
  3703.      perhaps, but it is better to be safe than sorry.  After all, it
  3704.      should be easier for you to provide an example that uses your
  3705.      actual situation, and it is by all means better for us.  In case
  3706.      you have data that you don't want to show to others, you can use
  3707.      FTP to transfer it to `ftp://ftp.mysql.com/pub/mysql/upload/'.  If
  3708.      the information is really top secret and you don't want to show it
  3709.      even to us, then go ahead and provide an example using other
  3710.      names, but please regard this as the last choice.
  3711.  
  3712.    * Include all the options given to the relevant programs, if
  3713.      possible.  For example, indicate the options that you use when you
  3714.      start the `mysqld' server as well as the options that you use to
  3715.      run any MySQL client programs.  The options to programs such as
  3716.      `mysqld' and `mysql', and to the `configure' script, are often
  3717.      keys to answers and are very relevant.  It is never a bad idea to
  3718.      include them.  If you use any modules, such as Perl or PHP, please
  3719.      include the version numbers of those as well.
  3720.  
  3721.    * If your question is related to the privilege system, please
  3722.      include the output of `mysqlaccess', the output of `mysqladmin
  3723.      reload', and all the error messages you get when trying to
  3724.      connect.  When you test your privileges, you should first run
  3725.      `mysqlaccess'.  After this, execute `mysqladmin reload version'
  3726.      and try to connect with the program that gives you trouble.
  3727.      `mysqlaccess' can be found in the `bin' directory under your MySQL
  3728.      installation directory.
  3729.  
  3730.    * If you have a patch for a bug, do include it.  But don't assume
  3731.      that the patch is all we need, or that we will use it, if you
  3732.      don't provide some necessary information such as test cases
  3733.      showing the bug that your patch fixes.  We might find problems
  3734.      with your patch or we might not understand it at all; if so, we
  3735.      can't use it.
  3736.  
  3737.      If we can't verify exactly what the purpose of the patch is, we
  3738.      won't use it.  Test cases will help us here.  Show that the patch
  3739.      will handle all the situations that may occur.  If we find a
  3740.      borderline case (even a rare one) where the patch won't work, it
  3741.      may be useless.
  3742.  
  3743.    * Guesses about what the bug is, why it occurs, or what it depends on
  3744.      are usually wrong.  Even the MySQL team can't guess such things
  3745.      without first using a debugger to determine the real cause of a
  3746.      bug.
  3747.  
  3748.    * Indicate in your bug report that you have checked the reference
  3749.      manual and mail archive so that others know you have tried to
  3750.      solve the problem yourself.
  3751.  
  3752.    * If you get a `parse error', please check your syntax closely.  If
  3753.      you can't find something wrong with it, it's extremely likely that
  3754.      your current version of MySQL Server doesn't support the syntax
  3755.      you are using.  If you are using the current version and the
  3756.      manual at `http://dev.mysql.com/doc/' doesn't cover the syntax you
  3757.      are using, MySQL Server doesn't support your query.  In this case,
  3758.      your only options are to implement the syntax yourself or email
  3759.      <licensing@mysql.com> and ask for an offer to implement it.
  3760.  
  3761.      If the manual covers the syntax you are using, but you have an
  3762.      older version of MySQL Server, you should check the MySQL change
  3763.      history to see when the syntax was implemented.  In this case, you
  3764.      have the option of upgrading to a newer version of MySQL Server.
  3765.      *Note News::.
  3766.  
  3767.    * If your problem is that your data appears corrupt or you get errors
  3768.      when you access a particular table, you should first check and
  3769.      then try to repair your tables with `CHECK TABLE' and `REPAIR
  3770.      TABLE' or with `myisamchk'.  *Note MySQL Database Administration::.
  3771.  
  3772.      If you are running Windows, please verify that
  3773.      `lower_case_table_names' is 1 or 2 with `SHOW VARIABLES LIKE
  3774.      'lower_case_table_names''.
  3775.  
  3776.    * If you often get corrupted tables, you should try to find out when
  3777.      and why this happens.  In this case, the error log in the MySQL
  3778.      data directory may contain some information about what happened.
  3779.      (This is the file with the `.err' suffix in the name.)  *Note
  3780.      Error log::.  Please include any relevant information from this
  3781.      file in your bug report.  Normally `mysqld' should _never_ crash a
  3782.      table if nothing killed it in the middle of an update.  If you can
  3783.      find the cause of `mysqld' dying, it's much easier for us to
  3784.      provide you with a fix for the problem.  *Note What is crashing::.
  3785.  
  3786.    * If possible, download and install the most recent version of MySQL
  3787.      Server and check whether it solves your problem.  All versions of
  3788.      the MySQL software are thoroughly tested and should work without
  3789.      problems.  We believe in making everything as backward-compatible
  3790.      as possible, and you should be able to switch MySQL versions
  3791.      without difficulty.  *Note Which version::.
  3792.  
  3793. If you are a support customer, please cross-post the bug report to
  3794. <mysql-support@mysql.com> for higher-priority treatment, as well as to
  3795. the appropriate mailing list to see whether someone else has
  3796. experienced (and perhaps solved) the problem.
  3797.  
  3798. For information on reporting bugs in `MyODBC', see *Note ODBC
  3799. Problems::.
  3800.  
  3801. For solutions to some common problems, see *Note Problems::.
  3802.  
  3803. When answers are sent to you individually and not to the mailing list,
  3804. it is considered good etiquette to summarize the answers and send the
  3805. summary to the mailing list so that others may have the benefit of
  3806. responses you received that helped you solve your problem.
  3807.  
  3808. Guidelines for Answering Questions on the Mailing List
  3809. ......................................................
  3810.  
  3811. If you consider your answer to have broad interest, you may want to
  3812. post it to the mailing list instead of replying directly to the
  3813. individual who asked.  Try to make your answer general enough that
  3814. people other than the original poster may benefit from it.  When you
  3815. post to the list, please make sure that your answer is not a
  3816. duplication of a previous answer.
  3817.  
  3818. Try to summarize the essential part of the question in your reply;
  3819. don't feel obliged to quote the entire original message.
  3820.  
  3821. Please don't post mail messages from your browser with HTML mode turned
  3822. on.  Many users don't read mail with a browser.
  3823.  
  3824. MySQL Community Support on IRC (Internet Relay Chat)
  3825. ----------------------------------------------------
  3826.  
  3827. In addition to the various MySQL mailing lists, you can find experienced
  3828. community people on `IRC' (`Internet Relay Chat').  These are the best
  3829. networks/channels currently known to us:
  3830.  
  3831.    * *freenode* (see `http://www.freenode.net/' for servers)
  3832.         * `#mysql' Primarily MySQL questions, but other database and
  3833.           general SQL questions are welcome.  Questions about PHP, Perl
  3834.           or C in combination with MySQL are also common.
  3835.  
  3836.    * *EFnet* (see `http://www.efnet.org/' for servers)
  3837.         * `#mysql' MySQL questions.
  3838.  
  3839. If you are looking for IRC client software to connect to an IRC network,
  3840. take a look at `X-Chat' (`http://www.xchat.org/').  X-Chat (GPL
  3841. licensed) is available for Unix as well as for Windows platforms.
  3842.  
  3843. MySQL Standards Compliance
  3844. ==========================
  3845.  
  3846. This section describes how MySQL relates to the ANSI/ISO SQL standards.
  3847. MySQL Server has many extensions to the SQL standard, and here you will
  3848. find out what they are and how to use them.  You will also find
  3849. information about functionality missing from MySQL Server, and how to
  3850. work around some differences.
  3851.  
  3852. The SQL standard has been evolving since 1986 and several versions
  3853. exist. In this manual, "SQL-92" refers to the standard released in 1992,
  3854. "SQL:1999" refers to the standard released in 1999, and "SQL:2003"
  3855. refers to the current version of the standard.  We use the phrase "the
  3856. SQL standard" to mean the current version of the SQL Standard at any
  3857. time.
  3858.  
  3859. Our goal is to not restrict MySQL Server usability for any usage
  3860. without a very good reason for doing so.  Even if we don't have the
  3861. resources to perform  development for every possible use, we are always
  3862. willing to help and offer suggestions to people who are trying to use
  3863. MySQL Server in new territories.
  3864.  
  3865. One of our main goals with the product is to continue to work toward
  3866. compliance with the SQL standard, but without sacrificing speed or
  3867. reliability.  We are not afraid to add extensions to SQL or support for
  3868. non-SQL features if this greatly increases the usability of MySQL
  3869. Server for a large segment of our user base.  The `HANDLER' interface
  3870. in MySQL Server 4.0 is an example of this strategy. *Note `HANDLER':
  3871. HANDLER.
  3872.  
  3873. We will continue to support transactional and non-transactional
  3874. databases to satisfy both mission-critical 24/7 usage and heavy Web or
  3875. logging usage.
  3876.  
  3877. MySQL Server was originally designed to work with medium size databases
  3878. (10-100 million rows, or about 100MB per table) on small computer
  3879. systems.  Today MySQL Server handles terabyte-size databases, but the
  3880. code can also be compiled in a reduced version suitable for hand-held
  3881. and embedded devices.  The compact design of the MySQL server makes
  3882. development in both directions possible without any conflicts in the
  3883. source tree.
  3884.  
  3885. Currently, we are not targeting realtime support, although MySQL
  3886. replication capabilities already offer significant functionality.
  3887.  
  3888. Database cluster support now exists through third-party clustering
  3889. solutions as well as the integration of our acquired NDB Cluster
  3890. technology into a new storage engine, available from version 4.1.2.
  3891. *Note NDBCluster::.
  3892.  
  3893. We are also looking at providing XML support in the database server.
  3894.  
  3895. What Standards MySQL Follows
  3896. ----------------------------
  3897.  
  3898. We are aiming toward supporting the full ANSI/ISO SQL standard, but
  3899. without making concessions to speed and quality of the code.
  3900.  
  3901. ODBC levels 0-3.51.
  3902.  
  3903. Selecting SQL Modes
  3904. -------------------
  3905.  
  3906. The MySQL server can operate in different SQL modes, and can apply these
  3907. modes differentially for different clients. This allows applications to
  3908. tailor server operation to their own requirements.
  3909.  
  3910. Modes define what SQL syntax MySQL should support and what kind of
  3911. validation checks it should perform on the data.  This makes it easier
  3912. to use MySQL in a lot of different environments and to use MySQL
  3913. together with other database servers.
  3914.  
  3915. You can set the default SQL mode by starting `mysqld' with the
  3916. `--sql-mode="modes"' option. Beginning with MySQL 4.1, you can also
  3917. change the mode after startup time by setting the `sql_mode' variable
  3918. with a `SET [SESSION|GLOBAL] sql_mode='modes'' statement.
  3919.  
  3920. For more information on setting the server mode, see *Note Server SQL
  3921. mode::.
  3922.  
  3923. Running MySQL in ANSI Mode
  3924. --------------------------
  3925.  
  3926. You can tell `mysqld' to use the ANSI mode with the `--ansi' startup
  3927. option. *Note Server options::.
  3928.  
  3929. Running the server in ANSI mode is the same as starting it with these
  3930. options (specify the `--sql_mode' value on a single line):
  3931.  
  3932.      --transaction-isolation=SERIALIZABLE
  3933.      --sql-mode=REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,
  3934.      IGNORE_SPACE,ONLY_FULL_GROUP_BY
  3935.  
  3936. In MySQL 4.1, you can achieve the same effect with these two statements
  3937. (specify the `sql_mode' value on a single line):
  3938.  
  3939.      SET GLOBAL TRANSACTION ISOLATION LEVEL SERIALIZABLE;
  3940.      SET GLOBAL sql_mode = 'REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,
  3941.      IGNORE_SPACE,ONLY_FULL_GROUP_BY';
  3942.  
  3943. *Note SQL mode::.
  3944.  
  3945. In MySQL 4.1.1, the `sql_mode' options shown can be also be set with
  3946. this statement:
  3947.  
  3948.      SET GLOBAL sql_mode='ansi';
  3949.  
  3950. In this case, the value of the `sql_mode' variable will be set to all
  3951. options that are relevant for ANSI mode. You can check the result like
  3952. this:
  3953.  
  3954.      mysql> SET GLOBAL sql_mode='ansi';
  3955.      mysql> SELECT @@global.sql_mode;
  3956.              -> 'REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,
  3957.                  IGNORE_SPACE,ONLY_FULL_GROUP_BY,ANSI';
  3958.  
  3959. MySQL Extensions to Standard SQL
  3960. --------------------------------
  3961.  
  3962. MySQL Server includes some extensions that you probably will not find in
  3963. other SQL databases.  Be warned that if you use them, your code will
  3964. not be portable to other SQL servers.  In some cases, you can write
  3965. code that includes MySQL extensions, but is still portable, by using
  3966. comments of the form `/*! ... */'.  In this case, MySQL Server will
  3967. parse and execute the code within the comment as it would any other
  3968. MySQL statement, but other SQL servers will ignore the extensions.  For
  3969. example:
  3970.  
  3971.      SELECT /*! STRAIGHT_JOIN */ col_name FROM table1,table2 WHERE ...
  3972.  
  3973. If you add a version number after the `!' character, the syntax within
  3974. the comment will be executed only if the MySQL version is equal to or
  3975. newer than the specified version number:
  3976.  
  3977.      CREATE /*!32302 TEMPORARY */ TABLE t (a INT);
  3978.  
  3979. This means that if you have Version 3.23.02 or newer, MySQL Server will
  3980. use the `TEMPORARY' keyword.
  3981.  
  3982. The following descriptions list MySQL extensions, organized by category.
  3983.  
  3984. Organization of data on disk
  3985.      MySQL Server maps each database to a directory under the MySQL
  3986.      data directory, and tables within a database to filenames in the
  3987.      database directory.  This has a few implications:
  3988.  
  3989.         * Database names and table names are case sensitive in MySQL
  3990.           Server on operating systems that have case-sensitive
  3991.           filenames (such as most Unix systems). *Note Name case
  3992.           sensitivity::.
  3993.  
  3994.         * You can use standard system commands to back up, rename,
  3995.           move, delete, and copy tables that are managed by the
  3996.           `MyISAM' or `ISAM' storage engines.  For example, to rename a
  3997.           `MyISAM' table, rename the `.MYD', `.MYI', and `.frm' files
  3998.           to which the table corresponds.
  3999.  
  4000.      Database, table, index, column, or alias names may begin with a
  4001.      digit (but may not consist solely of digits).
  4002.  
  4003. General language syntax
  4004.         * Strings may be enclosed by either `"' or `'', not just by `''.
  4005.  
  4006.         * Use of `\' as an escape character in strings.
  4007.  
  4008.         * In SQL statements, you can access tables from different
  4009.           databases with the DB_NAME.TBL_NAME syntax.  Some SQL servers
  4010.           provide the same functionality but call this `User space'.
  4011.           MySQL Server doesn't support tablespaces such as used in
  4012.           statements like this: `CREATE TABLE ralph.my_table...IN
  4013.           my_tablespace'.
  4014.  
  4015.  
  4016. SQL statement syntax
  4017.         * The `ANALYZE TABLE', `CHECK TABLE', `OPTIMIZE TABLE', and
  4018.           `REPAIR TABLE' statements.
  4019.  
  4020.         * The `CREATE DATABASE' and `DROP DATABASE' statements.  *Note
  4021.           `CREATE DATABASE': CREATE DATABASE.
  4022.  
  4023.         * The `DO' statement.
  4024.  
  4025.         * `EXPLAIN SELECT' to get a description of how tables are
  4026.           joined.
  4027.  
  4028.         * The `FLUSH' and `RESET' statements.
  4029.  
  4030.         * The `SET' statement. *Note `SET': SET OPTION.
  4031.  
  4032.         * The `SHOW' statement.  *Note `SHOW': SHOW.
  4033.  
  4034.         * Use of `LOAD DATA INFILE'. In many cases, this syntax is
  4035.           compatible with Oracle's `LOAD DATA INFILE'. *Note `LOAD
  4036.           DATA': LOAD DATA.
  4037.  
  4038.         * Use of `RENAME TABLE'. *Note `RENAME TABLE': RENAME TABLE.
  4039.  
  4040.         * Use of `REPLACE' instead of `DELETE' + `INSERT'.  *Note
  4041.           `REPLACE': REPLACE.
  4042.  
  4043.         * Use of `CHANGE col_name', `DROP col_name', or `DROP INDEX',
  4044.           `IGNORE' or `RENAME' in an `ALTER TABLE' statement.  Use of
  4045.           multiple `ADD', `ALTER', `DROP', or `CHANGE' clauses in an
  4046.           `ALTER TABLE' statement.  *Note `ALTER TABLE': ALTER TABLE.
  4047.  
  4048.         * Use of index names, indexes on a prefix of a field, and use of
  4049.           `INDEX' or `KEY' in a `CREATE TABLE' statement. *Note `CREATE
  4050.           TABLE': CREATE TABLE.
  4051.  
  4052.         * Use of `TEMPORARY' or `IF NOT EXISTS' with `CREATE TABLE'.
  4053.  
  4054.         * Use of `IF EXISTS' with `DROP TABLE'.
  4055.  
  4056.         * You can drop multiple tables with a single `DROP TABLE'
  4057.           statement.
  4058.  
  4059.         * The `ORDER BY' and `LIMIT' clauses of the `UPDATE' and
  4060.           `DELETE' statements.
  4061.  
  4062.         * `INSERT INTO ... SET col_name = ...' syntax.
  4063.  
  4064.         * The `DELAYED' clause of the `INSERT' and `REPLACE' statements.
  4065.  
  4066.         * The `LOW_PRIORITY' clause of the `INSERT', `REPLACE',
  4067.           `DELETE', and `UPDATE' statements.
  4068.  
  4069.         * Use of `INTO OUTFILE' and `STRAIGHT_JOIN' in a `SELECT'
  4070.           statement. *Note `SELECT': SELECT.
  4071.  
  4072.         * The `SQL_SMALL_RESULT' option in a `SELECT' statement.
  4073.  
  4074.         * You don't need to name all selected columns in the `GROUP BY'
  4075.           part.  This gives better performance for some very specific,
  4076.           but quite normal queries.  *Note Group by functions and
  4077.           modifiers::.
  4078.  
  4079.         * You can specify `ASC' and `DESC' with `GROUP BY'.
  4080.  
  4081.         * The ability to set variables in a statement with the `:='
  4082.           assignment operator:
  4083.                mysql> SELECT @a:=SUM(total),@b=COUNT(*),@a/@b AS avg
  4084.                    -> FROM test_table;
  4085.                mysql> SELECT @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3;
  4086.  
  4087.  
  4088. Column types
  4089.         * The column types `MEDIUMINT', `SET', `ENUM', and the
  4090.           different `BLOB' and `TEXT' types.
  4091.  
  4092.         * The column attributes `AUTO_INCREMENT', `BINARY', `NULL',
  4093.           `UNSIGNED', and `ZEROFILL'.
  4094.  
  4095. Functions and operators
  4096.         * To make it easier for users who come from other SQL
  4097.           environments, MySQL Server supports aliases for many
  4098.           functions. For example, all string functions support both
  4099.           standard SQL syntax and ODBC syntax.
  4100.  
  4101.         * MySQL Server understands the `||' and `&&' operators to mean
  4102.           logical OR and AND, as in the C programming language.  In
  4103.           MySQL Server, `||' and `OR' are synonyms, as are `&&' and
  4104.           `AND'.  Because of this nice syntax, MySQL Server doesn't
  4105.           support the standard SQL `||' operator for string
  4106.           concatenation; use `CONCAT()' instead. Because `CONCAT()'
  4107.           takes any number of arguments, it's easy to convert use of
  4108.           the `||' operator to MySQL Server.
  4109.  
  4110.         * Use of `COUNT(DISTINCT list)' where `list' has more than one
  4111.           element.
  4112.  
  4113.         * All string comparisons are case-insensitive by default, with
  4114.           sort ordering determined by the current character set
  4115.           (ISO-8859-1 Latin1 by default).  If you don't like this, you
  4116.           should declare your columns with the `BINARY' attribute or
  4117.           use the `BINARY' cast, which causes comparisons to be done
  4118.           using the underlying character code values rather then a
  4119.           lexical ordering.
  4120.  
  4121.         * The `%' operator is a synonym for `MOD()'.  That is, `N % M'
  4122.           is equivalent to `MOD(N,M)'.  `%' is supported for C
  4123.           programmers and for compatibility with PostgreSQL.
  4124.  
  4125.         * The `=', `<>', `<=' ,`<', `>=',`>', `<<', `>>', `<=>', `AND',
  4126.           `OR', or `LIKE' operators may be used in column comparisons
  4127.           to the left of the `FROM' in `SELECT' statements.  For
  4128.           example:
  4129.  
  4130.                mysql> SELECT col1=1 AND col2=2 FROM TBL_NAME;
  4131.  
  4132.         * The `LAST_INSERT_ID()' function that returns the most recent
  4133.           `AUTO_INCREMENT' value.  *Note Information functions::.
  4134.  
  4135.         * `LIKE' is allowed on numeric columns.
  4136.  
  4137.         * The `REGEXP' and `NOT REGEXP' extended regular expression
  4138.           operators.
  4139.  
  4140.         * `CONCAT()' or `CHAR()' with one argument or more than two
  4141.           arguments.  (In MySQL Server, these functions can take any
  4142.           number of arguments.)
  4143.  
  4144.         * The `BIT_COUNT()', `CASE', `ELT()', `FROM_DAYS()',
  4145.           `FORMAT()', `IF()', `PASSWORD()', `ENCRYPT()', `MD5()',
  4146.           `ENCODE()', `DECODE()', `PERIOD_ADD()', `PERIOD_DIFF()',
  4147.           `TO_DAYS()', and `WEEKDAY()' functions.
  4148.  
  4149.         * Use of `TRIM()' to trim substrings.  Standard SQL supports
  4150.           removal of single characters only.
  4151.  
  4152.         * The `GROUP BY' functions `STD()', `BIT_OR()', `BIT_AND()',
  4153.           `BIT_XOR()', and `GROUP_CONCAT()'.  *Note Group by functions
  4154.           and modifiers::.
  4155.  
  4156. For a prioritized list indicating when new extensions will be added to
  4157. MySQL Server, you should consult the online MySQL TODO list at
  4158. `http://dev.mysql.com/doc/mysql/en/TODO.html'.  That is the latest
  4159. version of the TODO list in this manual. *Note TODO::.
  4160.  
  4161. MySQL Differences from Standard SQL
  4162. -----------------------------------
  4163.  
  4164. We try to make MySQL Server follow the ANSI SQL standard and the ODBC
  4165. SQL standard, but MySQL Server performs operations differently in some
  4166. cases:
  4167.  
  4168.    * For `VARCHAR' columns, trailing spaces are removed when the value
  4169.      is stored. *Note Bugs::.
  4170.  
  4171.    * In some cases, `CHAR' columns are silently converted to `VARCHAR'
  4172.      columns when you define a table or alter its structure.  *Note
  4173.      Silent column changes::.
  4174.  
  4175.    * Privileges for a table are not automatically revoked when you
  4176.      delete a table. You must explicitly issue a `REVOKE' statement to
  4177.      revoke privileges for a table. *Note `GRANT': GRANT.
  4178.  
  4179. Subqueries
  4180. ..........
  4181.  
  4182. MySQL 4.1 supports subqueries and derived tables.  A "subquery" is a
  4183. `SELECT' statement nested within another statement.  A "derived table"
  4184. (an unnamed view) is a subquery in the `FROM' clause of another
  4185. statement.  *Note Subqueries::.
  4186.  
  4187. For MySQL versions older than 4.1, most subqueries can be rewritten
  4188. using joins or other methods.  See *Note Rewriting subqueries:: for
  4189. examples that show how to do this.
  4190.  
  4191. `SELECT INTO TABLE'
  4192. ...................
  4193.  
  4194. MySQL Server doesn't support the Sybase SQL extension: `SELECT ... INTO
  4195. TABLE ...'.  Instead, MySQL Server supports the standard SQL syntax
  4196. `INSERT INTO ... SELECT ...', which is basically the same thing. *Note
  4197. `INSERT SELECT': INSERT SELECT.
  4198.  
  4199.      INSERT INTO tbl_temp2 (fld_id)
  4200.          SELECT tbl_temp1.fld_order_id
  4201.          FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;
  4202.  
  4203. Alternatively, you can use `SELECT INTO OUTFILE ...' or `CREATE TABLE
  4204. ... SELECT'.
  4205.  
  4206. From version 5.0, MySQL supports `SELECT ... INTO' with user variables.
  4207. The same syntax may also be used inside stored procedures using cursors
  4208. and local variables.  *Note SELECT INTO Statement::.
  4209.  
  4210. Transactions and Atomic Operations
  4211. ..................................
  4212.  
  4213. MySQL Server (version 3.23-max and all versions 4.0 and above) supports
  4214. transactions with the `InnoDB' and `BDB' transactional storage engines.
  4215. `InnoDB' provides _full_ `ACID' compliance.  *Note Table types::.
  4216.  
  4217. The other non-transactional storage engines in MySQL Server (such as
  4218. `MyISAM') follow a different paradigm for data integrity called "atomic
  4219. operations." In transactional terms, `MyISAM' tables effectively always
  4220. operate in `AUTOCOMMIT=1' mode.  Atomic operations often offer
  4221. comparable integrity with higher performance.
  4222.  
  4223. With MySQL Server supporting both paradigms, you can decide whether your
  4224. applications are best served by the speed of atomic operations or the
  4225. use of transactional features. This choice can be made on a per-table
  4226. basis.
  4227.  
  4228. As noted, the trade-off for transactional versus non-transactional table
  4229. types lies mostly in performance. Transactional tables have
  4230. significantly higher memory and diskspace requirements, and more CPU
  4231. overhead.  On the other hand, transactional table types such as
  4232. `InnoDB' also offer many significant features. MySQL Server's modular
  4233. design allows the concurrent use of different storage engines to suit
  4234. different requirements and deliver optimum performance in all
  4235. situations.
  4236.  
  4237. But how do you use the features of MySQL Server to maintain rigorous
  4238. integrity even with the non-transactional `MyISAM' tables, and how do
  4239. these features compare with the transactional table types?
  4240.  
  4241.   1. If your applications are written in a way that is dependent on
  4242.      being able to call `ROLLBACK' rather than `COMMIT' in critical
  4243.      situations, transactions are more convenient. Transactions also
  4244.      ensure that unfinished updates or corrupting activities are not
  4245.      committed to the database; the server is given the opportunity to
  4246.      do an automatic rollback and your database is saved.
  4247.  
  4248.      If you use non-transactional tables, MySQL Server in almost all
  4249.      cases allows you to resolve potential problems by including simple
  4250.      checks before updates and by running simple scripts that check the
  4251.      databases for inconsistencies and automatically repair or warn if
  4252.      such an inconsistency occurs. Note that just by using the MySQL
  4253.      log or even adding one extra log, you can normally fix tables
  4254.      perfectly with no data integrity loss.
  4255.  
  4256.   2. More often than not, critical transactional updates can be
  4257.      rewritten to be atomic. Generally speaking, all integrity problems
  4258.      that transactions solve can be done with `LOCK TABLES' or atomic
  4259.      updates, ensuring that you never will get an automatic abort from
  4260.      the server, which is a common problem with transactional database
  4261.      systems.
  4262.  
  4263.   3. Even a transactional system can lose data if the server goes down.
  4264.      The difference between different systems lies in just how small the
  4265.      time-lag is where they could lose data. No system is 100% secure,
  4266.      only "secure enough." Even Oracle, reputed to be the safest of
  4267.      transactional database systems, is reported to sometimes lose data
  4268.      in such situations.
  4269.  
  4270.      To be safe with MySQL Server, whether or not using transactional
  4271.      tables, you only need to have backups and have binary logging
  4272.      turned on. With this you can recover from any situation that you
  4273.      could with any other transactional database system.  It is always
  4274.      good to have backups, regardless of which database system you use.
  4275.  
  4276. The transactional paradigm has its benefits and its drawbacks. Many
  4277. users and application developers depend on the ease with which they can
  4278. code around problems where an abort appears to be, or is necessary.
  4279. However, even if you are new to the atomic operations paradigm, or more
  4280. familiar with transactions, do consider the speed benefit that
  4281. non-transactional tables can offer on the order of three to five times
  4282. the speed of the fastest and most optimally tuned transactional tables.
  4283.  
  4284. In situations where integrity is of highest importance, MySQL Server
  4285. offers transaction-level reliability and integrity even for
  4286. non-transactional tables.  If you lock tables with `LOCK TABLES', all
  4287. updates will stall until any integrity checks are made. If you obtain a
  4288. `READ LOCAL' lock (as opposed to a write lock) for a table that allows
  4289. concurrent inserts at the end of the table, reads are allowed, as are
  4290. inserts by other clients.  The new inserted records will not be seen by
  4291. the client that has the read lock until it releases the lock.  With
  4292. `INSERT DELAYED', you can queue inserts into a local queue, until the
  4293. locks are released, without having the client wait for the insert to
  4294. complete. *Note INSERT DELAYED::.
  4295.  
  4296. "Atomic," in the sense that we mean it, is nothing magical. It only
  4297. means that you can be sure that while each specific update is running,
  4298. no other user can interfere with it, and there will never be an
  4299. automatic rollback (which can happen with transactional tables if you
  4300. are not very careful).  MySQL Server also guarantees that there will
  4301. not be any dirty reads.
  4302.  
  4303. Following are some techniques for working with non-transactional tables:
  4304.  
  4305.    * Loops that need transactions normally can be coded with the help of
  4306.      `LOCK TABLES', and you don't need cursors to update records on the
  4307.      fly.
  4308.  
  4309.    * To avoid using `ROLLBACK', you can use the following strategy:
  4310.  
  4311.        1. Use `LOCK TABLES' to lock all the tables you want to access.
  4312.  
  4313.        2. Test the conditions that must be true before performing the
  4314.           update.
  4315.  
  4316.        3. Update if everything is okay.
  4317.  
  4318.        4. Use `UNLOCK TABLES' to release your locks.
  4319.  
  4320.      This is usually a much faster method than using transactions with
  4321.      possible rollbacks, although not always. The only situation this
  4322.      solution doesn't handle is when someone kills the threads in the
  4323.      middle of an update. In this case, all locks will be released but
  4324.      some of the updates may not have been executed.
  4325.  
  4326.    * You can also use functions to update records in a single operation.
  4327.      You can get a very efficient application by using the following
  4328.      techniques:
  4329.  
  4330.         * Modify columns relative to their current value.
  4331.  
  4332.         * Update only those columns that actually have changed.
  4333.  
  4334.      For example, when we are doing updates to some customer
  4335.      information, we update only the customer data that has changed and
  4336.      test only that none of the changed data, or data that depends on
  4337.      the changed data, has changed compared to the original row. The
  4338.      test for changed data is done with the `WHERE' clause in the
  4339.      `UPDATE' statement. If the record wasn't updated, we give the
  4340.      client a message: "Some of the data you have changed has been
  4341.      changed by another user." Then we show the old row versus the new
  4342.      row in a window so that the user can decide which version of the
  4343.      customer record to use.
  4344.  
  4345.      This gives us something that is similar to column locking but is
  4346.      actually even better because we only update some of the columns,
  4347.      using values that are relative to their current values.  This
  4348.      means that typical `UPDATE' statements look something like these:
  4349.  
  4350.           UPDATE tablename SET pay_back=pay_back+125;
  4351.           
  4352.           UPDATE customer
  4353.             SET
  4354.               customer_date='current_date',
  4355.               address='new address',
  4356.               phone='new phone',
  4357.               money_owed_to_us=money_owed_to_us-125
  4358.             WHERE
  4359.               customer_id=id AND address='old address' AND phone='old phone';
  4360.  
  4361.      This is very efficient and works even if another client has
  4362.      changed the values in the `pay_back' or `money_owed_to_us' columns.
  4363.  
  4364.    * In many cases, users have wanted `LOCK TABLES' and/or `ROLLBACK'
  4365.      for the purpose of managing unique identifiers.  This can be
  4366.      handled much more efficiently without locking or rolling back by
  4367.      using an `AUTO_INCREMENT' column and either the `LAST_INSERT_ID()'
  4368.      SQL function or the `mysql_insert_id()' C API function.  *Note
  4369.      Information functions::.  *Note `mysql_insert_id()':
  4370.      mysql_insert_id.
  4371.  
  4372.      You can generally code around the need for row-level locking. Some
  4373.      situations really do need it, and `InnoDB' tables support
  4374.      row-level locking. With `MyISAM' tables, you can use a flag column
  4375.      in the table and do something like the following:
  4376.  
  4377.           UPDATE TBL_NAME SET row_flag=1 WHERE id=ID;
  4378.  
  4379.      MySQL returns 1 for the number of affected rows if the row was
  4380.      found and `row_flag' wasn't already 1 in the original row.
  4381.  
  4382.      You can think of it as though MySQL Server changed the preceding
  4383.      query to:
  4384.  
  4385.           UPDATE TBL_NAME SET row_flag=1 WHERE id=ID AND row_flag <> 1;
  4386.  
  4387. Stored Procedures and Triggers
  4388. ..............................
  4389.  
  4390. Stored procedures are implemented in MySQL version 5.0.  *Note Stored
  4391. Procedures::.
  4392.  
  4393. Triggers are scheduled for implementation in MySQL version 5.1. A
  4394. "trigger" is effectively a type of stored procedure, one that is
  4395. invoked when a particular event occurs.  For example, you could set up
  4396. a stored procedure that is triggered each time a record is deleted from
  4397. a transactional table, and that stored procedure automatically deletes
  4398. the corresponding customer from a customer table when all their
  4399. transactions are deleted.
  4400.  
  4401. Foreign Keys
  4402. ............
  4403.  
  4404. In MySQL Server 3.23.44 and up, the `InnoDB' storage engine supports
  4405. checking of foreign key constraints, including `CASCADE', `ON DELETE',
  4406. and `ON UPDATE'. *Note InnoDB foreign key constraints::.
  4407.  
  4408. For storage engines other than `InnoDB', MySQL Server parses the
  4409. `FOREIGN KEY' syntax in `CREATE TABLE' statements, but does not use or
  4410. store it. In the future, the implementation will be extended to store
  4411. this information in the table specification file so that it may be
  4412. retrieved by `mysqldump' and ODBC.  At a later stage, foreign key
  4413. constraints will be implemented for `MyISAM' tables as well.
  4414.  
  4415. Foreign key enforcement offers several benefits to database developers:
  4416.  
  4417.    * Assuming proper design of the relationships, foreign key
  4418.      constraints make it more difficult for a programmer to introduce
  4419.      an inconsistency into the database.
  4420.  
  4421.    * Centralized checking of constraints by the database server makes it
  4422.      unnecessary to perform these checks on the application side. This
  4423.      eliminates the possibility that different applications may not all
  4424.      check the constraints in the same way.
  4425.  
  4426.    * Using cascading updates and deletes can simplify the application
  4427.      code.
  4428.  
  4429.    * Properly designed foreign key rules aid in documenting
  4430.      relationships between tables.
  4431.  
  4432. Do keep in mind that these benefits come at the cost of additional
  4433. overhead for the database server to perform the necessary checks.
  4434. Additional checking by the server affects performance, which for some
  4435. applications may be sufficiently undesirable as to be avoided if
  4436. possible.  (Some major commercial applications have coded the
  4437. foreign-key logic at the application level for this reason.)
  4438.  
  4439. MySQL gives database developers the choice of which approach to use. If
  4440. you don't need foreign keys and want to avoid the overhead associated
  4441. with enforcing referential integrity, you can choose another table type
  4442. instead, such as `MyISAM'. (For example, the `MyISAM' storage engine
  4443. offers very fast performance for applications that perform only
  4444. `INSERT' and `SELECT' operations, because the inserts can be performed
  4445. concurrently with retrievals.  *Note Table locking::.)
  4446.  
  4447. If you choose not to take advantage of referential integrity checks,
  4448. keep the following considerations in mind:
  4449.  
  4450.    * In the absence of server-side foreign key relationship checking,
  4451.      the application itself must handle relationship issues.  For
  4452.      example, it must take care to insert rows into tables in the proper
  4453.      order, and to avoid creating orphaned child records. It must also
  4454.      be able to recover from errors that occur in the middle of
  4455.      multiple-record insert operations.
  4456.  
  4457.    * If `ON DELETE' is the only referential integrity capability an
  4458.      application needs, note that as of MySQL Server 4.0, you can use
  4459.      multiple-table `DELETE' statements to delete rows from many tables
  4460.      with a single statement. *Note `DELETE': DELETE.
  4461.  
  4462.    * A workaround for the lack of `ON DELETE' is to add the appropriate
  4463.      `DELETE' statement to your application when you delete records
  4464.      from a table that has a foreign key. In practice, this is often as
  4465.      quick as using foreign keys, and is more portable.
  4466.  
  4467.  
  4468. Be aware that the use of foreign keys can in some instances lead to
  4469. problems:
  4470.  
  4471.    * Foreign key support addresses many referential integrity issues,
  4472.      but it is still necessary to design key relationships carefully to
  4473.      avoid circular rules or incorrect combinations of cascading
  4474.      deletes.
  4475.  
  4476.    * It is not uncommon for a DBA to create a topology of relationships
  4477.      that makes it difficult to restore individual tables from a backup.
  4478.      (MySQL alleviates this difficulty by allowing you to temporarily
  4479.      disable foreign key checks when reloading a table that depends on
  4480.      other tables.  *Note InnoDB foreign key constraints::.  As of
  4481.      MySQL 4.1.1, `mysqldump' generates dump files that take advantage
  4482.      of this capability automatically when reloaded.)
  4483.  
  4484. Note that foreign keys in SQL are used to check and enforce referential
  4485. integrity, not to join tables.  If you want to get results from multiple
  4486. tables from a `SELECT' statement, you do this by performing a join
  4487. between them:
  4488.  
  4489.      SELECT * FROM t1, t2 WHERE t1.id = t2.id;
  4490.  
  4491. *Note `JOIN': JOIN. *Note example-Foreign keys::.
  4492.  
  4493. The `FOREIGN KEY' syntax without `ON DELETE ...' is often used by ODBC
  4494. applications to produce automatic `WHERE' clauses.
  4495.  
  4496. Views
  4497. .....
  4498.  
  4499. Views are being implemented in the 5.0 version of MySQL Server. While
  4500. still under development, they are already available in the 5.0 BitKeeper
  4501. tree and will be present in binary releases from 5.0.1 and up.  Unnamed
  4502. views (_derived tables_, a subquery in the `FROM' clause of a `SELECT')
  4503. are already implemented in version 4.1.  Unqualified union views
  4504. (`SELECT ... UNION SELECT ...' are also available through the `MERGE'
  4505. table feature.  *Note MERGE::.
  4506.  
  4507. Historically, MySQL Server has been most used in applications and on Web
  4508. systems where the application writer has full control over database
  4509. usage. Usage has shifted over time, and so we find that an increasing
  4510. number of users now regard views as an important feature.
  4511.  
  4512. Views are useful for allowing users to access a set of relations
  4513. (tables) as if it were a single table, and limiting their access to
  4514. just that.  Views can also be used to restrict access to rows (a subset
  4515. of a particular table).  For access control to columns, you can also
  4516. use the sophisticated privilege system in MySQL Server.  *Note
  4517. Privilege system::.
  4518.  
  4519. Many DBMS don't allow updates to a view. Instead, you have to perform
  4520. the updates on the individual tables.  In designing an implementation
  4521. of views, our goal, as much as is possible within the confines of SQL,
  4522. is full compliance with "Codd's Rule #6" for relational database
  4523. systems: All views that are theoretically updatable, should in practice
  4524. also be updatable.
  4525.  
  4526. `--' as the Start of a Comment
  4527. ..............................
  4528.  
  4529. Some other SQL databases use `--' to start comments.  MySQL Server uses
  4530. `#' as the start comment character. You can also use the C comment
  4531. style `/* this is a comment */' with MySQL Server.  *Note Comments::.
  4532.  
  4533. MySQL Server 3.23.3 and above support the `--' comment style, provided
  4534. the comment is followed by a space (or by a control character such as a
  4535. newline). The requirement for a space is to prevent problems with
  4536. automatically generated SQL queries that have used something like the
  4537. following code, where we automatically insert the value of the payment
  4538. for `!payment!':
  4539.  
  4540.      UPDATE account SET credit=credit-!payment!
  4541.  
  4542. Think about what happens if the value of `payment' is a negative value
  4543. such as `-1':
  4544.  
  4545.      UPDATE account SET credit=credit--1
  4546.  
  4547. `credit--1' is a legal expression in SQL, but if `--' is interpreted as
  4548. the start of a comment, part of the expression is discarded. The result
  4549. is a statement that has a completely different meaning than intended:
  4550.  
  4551.      UPDATE account SET credit=credit
  4552.  
  4553. The statement produces no change in value at all!  This illustrates that
  4554. allowing comments to start with `--' can have serious consequences.
  4555.  
  4556. Using our implementation of this method of commenting in MySQL Server
  4557. 3.23.3 and up, `credit--1' is actually safe.
  4558.  
  4559. Another safe feature is that the `mysql' command-line client removes
  4560. all lines that start with `--'.
  4561.  
  4562. The following information is relevant only if you are running a MySQL
  4563. version earlier than 3.23.3:
  4564.  
  4565. If you have an SQL program in a text file that contains `--' comments,
  4566. you should use the `replace' utility as follows to convert the comments
  4567. to use `#' characters:
  4568.  
  4569.      shell> replace " --" " #" < text-file-with-funny-comments.sql \
  4570.               | mysql DB_NAME
  4571.  
  4572. instead of the usual:
  4573.  
  4574.      shell> mysql DB_NAME < text-file-with-funny-comments.sql
  4575.  
  4576. You can also edit the command file "in place" to change the `--'
  4577. comments to `#' comments:
  4578.  
  4579.      shell> replace " --" " #" -- text-file-with-funny-comments.sql
  4580.  
  4581. Change them back with this command:
  4582.  
  4583.      shell> replace " #" " --" -- text-file-with-funny-comments.sql
  4584.  
  4585. How MySQL Deals with Constraints
  4586. --------------------------------
  4587.  
  4588. MySQL allows you to work with both transactional tables that allow
  4589. rollback and non-transactional tables that do not, so constraint
  4590. handling is a bit different in MySQL than in other databases.
  4591.  
  4592. We have to handle the case when you have updated a lot of rows in a
  4593. non-transactional table that cannot roll back when an error occurs.
  4594.  
  4595. The basic philosophy is to try to give an error for anything that we can
  4596. detect at compile time but try to recover from any errors we get at
  4597. runtime.  We do this in most cases, but not yet for all. *Note TODO
  4598. future::.
  4599.  
  4600. The options MySQL has when an error occurs are to stop the statement in
  4601. the middle or to recover as well as possible from the problem and
  4602. continue.
  4603.  
  4604. The following sections describe what happens for the different types of
  4605. constraints.
  4606.  
  4607. Constraint `PRIMARY KEY' / `UNIQUE'
  4608. ...................................
  4609.  
  4610. Normally you will get an error when you try to `INSERT' or `UPDATE' a
  4611. row that causes a primary key, unique key, or foreign key violation.
  4612. If you are using a transactional storage engine such as `InnoDB', MySQL
  4613. will automatically roll back the transaction.  If you are using a
  4614. non-transactional storage engine, MySQL will stop at the incorrect row
  4615. and leave any remaining rows unprocessed.
  4616.  
  4617. To make life easier, MySQL supports an `IGNORE' keyword for most
  4618. commands that can cause a key violation (such as `INSERT IGNORE' and
  4619. `UPDATE IGNORE'). In this case, MySQL will ignore any key violation and
  4620. continue with processing the next row.  You can get information about
  4621. what MySQL did with the `mysql_info()' C API function.  *Note
  4622. `mysql_info()': mysql_info.  In MySQL 4.1 and up, you also can use the
  4623. `SHOW WARNINGS' statement.  *Note SHOW WARNINGS::.
  4624.  
  4625. Note that, for the moment, only `InnoDB' tables support foreign keys.
  4626. *Note InnoDB foreign key constraints::.  Foreign key support in
  4627. `MyISAM' tables is scheduled for implementation in MySQL 5.1.
  4628.  
  4629. Constraint `NOT NULL' and `DEFAULT' Values
  4630. ..........................................
  4631.  
  4632. To be able to support easy handling of non-transactional tables, all
  4633. columns in MySQL have default values.
  4634.  
  4635. If you insert an "incorrect" value into a column, such as a `NULL' into
  4636. a `NOT NULL' column or a too-large numerical value into a numerical
  4637. column, MySQL sets the column to the "best possible value" instead of
  4638. producing an error:
  4639.  
  4640.    * If you try to store a value outside the range in a numerical
  4641.      column, MySQL Server instead stores zero, the smallest possible
  4642.      value, or the largest possible value in the column.
  4643.  
  4644.    * For strings, MySQL stores either the empty string or the longest
  4645.      possible string that can be in the column.
  4646.  
  4647.    * If you try to store a string that doesn't start with a number into
  4648.      a numerical column, MySQL Server stores 0.
  4649.  
  4650.    * If you try to store `NULL' into a column that doesn't take `NULL'
  4651.      values, MySQL Server stores 0 or `''' (the empty string) instead.
  4652.      This last behavior can, for single-row inserts, be changed when
  4653.      MySQL is built by using the `-DDONT_USE_DEFAULT_FIELDS' compile
  4654.      option.) *Note `configure' options: configure options.  This
  4655.      causes `INSERT' statements to generate an error unless you
  4656.      explicitly specify values for all columns that require a
  4657.      non-`NULL' value.
  4658.  
  4659.    * MySQL allows you to store some incorrect date values into `DATE'
  4660.      and `DATETIME' columns (like `'2000-02-31'' or `'2000-02-00'').
  4661.      The idea is that it's not the job of the SQL server to validate
  4662.      dates. If MySQL can store a date value and retrieve exactly the
  4663.      same value, MySQL stores it as given.  If the date is totally
  4664.      wrong (outside the server's ability to store it), the special date
  4665.      value `'0000-00-00'' is stored in the column instead.
  4666.  
  4667.  
  4668. The reason for the preceding rules is that we can't check these
  4669. conditions until the query has begun executing.  We can't just roll
  4670. back if we encounter a problem after updating a few rows, because the
  4671. table type may not support rollback.  The option of terminating the
  4672. statement is not that good; in this case, the update would be "half
  4673. done," which is probably the worst possible scenario.  In this case,
  4674. it's better to "do the best you can" and then continue as if nothing
  4675. happened.
  4676.  
  4677. This means that you should generally not use MySQL to check column
  4678. content.  Instead, the application should ensure that it passes only
  4679. legal values to MySQL.
  4680.  
  4681. In MySQL 5.0, we plan to improve this by providing warnings when
  4682. automatic column conversions occur, plus an option to let you roll back
  4683. statements that attempt to perform a disallowed column value
  4684. assignment, as long as the statement uses only transactional tables.
  4685.  
  4686. Constraint `ENUM' and `SET'
  4687. ...........................
  4688.  
  4689. In MySQL 4.x, `ENUM' is not a real constraint, but is a more efficient
  4690. way to define columns that can contain only a given set of values.
  4691. This is for the same reasons that `NOT NULL' is not honored.  *Note
  4692. constraint NOT NULL::.
  4693.  
  4694. If you insert an incorrect value into an `ENUM' column, it is set to
  4695. the reserved enumeration value of `0', which is displayed as an empty
  4696. string in string context. *Note ENUM::.
  4697.  
  4698. If you insert an incorrect value into a `SET' column, the incorrect
  4699. value is ignored. For example, if the column can contain the values
  4700. `'a'', `'b'', and `'c'', an attempt to assign `'a,x,b,y'' results in a
  4701. value of `'a,b''.  *Note SET::.
  4702.  
  4703. Known Errors and Design Deficiencies in MySQL
  4704. ---------------------------------------------
  4705.  
  4706. Errors in 3.23 Fixed in a Later MySQL Version
  4707. .............................................
  4708.  
  4709. The following known errors or bugs are not fixed in MySQL 3.23 because
  4710. fixing them would involve changing a lot of code that could introduce
  4711. other even worse bugs. The bugs are also classified as "not fatal" or
  4712. "bearable."
  4713.  
  4714.    * One should avoid having space at end of field names as this can
  4715.      cause weird behaviour. (Fixed in MySQL 4.0). (Bug #4196)
  4716.  
  4717.    * You can get a deadlock (hung thread) if you use `LOCK TABLE' to
  4718.      lock multiple tables and then in the same connection use `DROP
  4719.      TABLE' to drop one of them while another thread is trying to lock
  4720.      it.  (To break the deadlock, you can use `KILL' to terminate any
  4721.      of the threads involved.)  This issue is resolved as of MySQL
  4722.      4.0.12.
  4723.  
  4724.    * `SELECT MAX(key_column) FROM t1,t2,t3...' where one of the tables
  4725.      are empty doesn't return `NULL' but instead returns the maximum
  4726.      value for the column.  This issue is resolved as of MySQL 4.0.11.
  4727.  
  4728.    * `DELETE FROM heap_table' without a `WHERE' clause doesn't work on
  4729.      a locked `HEAP' table.
  4730.  
  4731. Errors in 4.0 Fixed in a Later MySQL Version
  4732. ............................................
  4733.  
  4734. The following known errors or bugs are not fixed in MySQL 4.0 because
  4735. fixing them would involve changing a lot of code that could introduce
  4736. other even worse bugs. The bugs are also classified as "not fatal" or
  4737. "bearable."
  4738.  
  4739.    * In a `UNION', the first `SELECT' determines the type,
  4740.      `max_length', and `NULL' properties for the resulting columns.
  4741.      This issue is resolved as of MySQL 4.1.1; the property values are
  4742.      based on the rows from all `UNION' parts.
  4743.  
  4744.    * In `DELETE' with many tables, you can't refer to tables to be
  4745.      deleted through an alias. This is fixed as of MySQL 4.1.
  4746.  
  4747.    * You cannot mix `UNION ALL' and `UNION DISTINCT' in the same query.
  4748.      If you use `ALL' for one `UNION', it is used for all of them.
  4749.      This is fixed as of MySQL 4.1.2. The rules for mixed `UNION' types
  4750.      are given in *Note `UNION': UNION.
  4751.  
  4752.    * `FLUSH TABLES WITH READ LOCK' does not block `CREATE TABLE', which
  4753.      may cause a problem with the binary log position when doing a full
  4754.      backup of tables and the binary log.
  4755.  
  4756. Open Bugs and Design Deficiencies in MySQL
  4757. ..........................................
  4758.  
  4759. The following problems are known and fixing them is a high priority:
  4760.  
  4761.    * Even if you are using `lower_case_table_names=2' (which enables
  4762.      MySQL to remember the used case for databases and table names)
  4763.      MySQL will not on case insensitive systems remember the used case
  4764.      for database names for the function `DATABASE()' or in various
  4765.      logs.
  4766.  
  4767.    * Dropping a `FOREIGN KEY' constraint doesn't work in replication
  4768.      because the constraint may have another name on the slave.
  4769.  
  4770.    * `REPLACE' (and `LOAD DATA' with the `REPLACE' option) does not
  4771.      trigger `ON DELETE CASCADE'.
  4772.  
  4773.    * `DISTINCT' with `ORDER BY' doesn't work inside `GROUP_CONCAT()' if
  4774.      you don't use all and only those columns that are in the
  4775.      `DISTINCT' list.
  4776.  
  4777.    * `GROUP_CONCAT()' doesn't work with `BLOB'/`TEXT' columns when you
  4778.      use `DISTINCT' or `ORDER BY' inside `GROUP_CONCAT()'. To work
  4779.      around this limitation, use `MID(EXPR,1,255)' instead.
  4780.  
  4781.    * If one user has a long-running transaction and another user drops a
  4782.      table that is updated in the transaction, there is small chance
  4783.      that the binary log may contain the `DROP TABLE' command before
  4784.      the table is used in the transaction itself.  We plan to fix this
  4785.      in 5.0 by having the `DROP TABLE' wait until the table is not used
  4786.      in any transaction.
  4787.  
  4788.    * When inserting a big integer value (between 2^63 and 2^64-1) into a
  4789.      decimal/string column, it is inserted as a negative value because
  4790.      the number is evaluated in a signed integer context. We plan to
  4791.      fix this in MySQL 4.1.
  4792.  
  4793.      `FLUSH TABLES WITH READ LOCK' does not block `COMMIT' if the server
  4794.      is running without binary logging, which may cause a problem (of
  4795.      consistency between tables) when doing a full backup.
  4796.  
  4797.    * `ANALYZE TABLE' on a `BDB' table may in some cases make the table
  4798.      unusable until you restart `mysqld'.  If this happens, you will
  4799.      see errors of the following form in the MySQL error file:
  4800.  
  4801.           001207 22:07:56  bdb:  log_flush: LSN past current end-of-log
  4802.  
  4803.    * MySQL accepts parentheses in the `FROM' clause of a `SELECT'
  4804.      statement, but silently ignores them.  The reason for not giving
  4805.      an error is that many clients that automatically generate queries
  4806.      add parentheses in the `FROM' clause even where they are not
  4807.      needed.
  4808.  
  4809.    * Concatenating many `RIGHT JOINS' or combining `LEFT' and `RIGHT'
  4810.      join in the same query may not give a correct answer because MySQL
  4811.      only generates `NULL' rows for the table preceding a `LEFT' or
  4812.      before a `RIGHT' join.  This will be fixed in 5.0 at the same time
  4813.      we add support for parentheses in the `FROM' clause.
  4814.  
  4815.    * Don't execute `ALTER TABLE' on a `BDB' table on which you are
  4816.      running multiple-statement transactions until all those
  4817.      transactions complete.  (The transaction will probably be ignored.)
  4818.  
  4819.    * `ANALYZE TABLE', `OPTIMIZE TABLE', and `REPAIR TABLE' may cause
  4820.      problems on tables for which you are using `INSERT DELAYED'.
  4821.  
  4822.    * Doing a `LOCK TABLE ...' and `FLUSH TABLES ...' doesn't guarantee
  4823.      that there isn't a half-finished transaction in progress on the
  4824.      table.
  4825.  
  4826.    * `BDB' tables are a bit slow to open. If you have many `BDB' tables
  4827.      in a database, it will take a long time to use the `mysql' client
  4828.      on the database if you are not using the `-A' option or if you are
  4829.      using `rehash'. This is especially notable when you have a large
  4830.      table cache.
  4831.  
  4832.    * Replication uses query-level logging: The master writes the
  4833.      executed queries to the binary log. This is a very fast, compact,
  4834.      and efficient logging method that works perfectly in most cases.
  4835.      Although we have never heard of it actually occurring, it is
  4836.      theoretically possible for the data on the master and slave to
  4837.      become different if a query is designed in such a way that the
  4838.      data modification is non-deterministic; that is, left to the will
  4839.      of the query optimizer. (That generally is not a good practice
  4840.      anyway, even outside of replication!)  For example:
  4841.  
  4842.         - `CREATE ... SELECT' or `INSERT ... SELECT'  statements that
  4843.           insert zero or `NULL' values into an `AUTO_INCREMENT' column.
  4844.  
  4845.         - `DELETE' if you are deleting rows from a table that has
  4846.           foreign keys with `ON DELETE CASCADE' properties.
  4847.  
  4848.         - `REPLACE ... SELECT', `INSERT IGNORE ... SELECT' if you have
  4849.           duplicate key values in the inserted data.
  4850.      *If and only if all these queries have no `ORDER BY' clause
  4851.      guaranteeing a deterministic order*.
  4852.  
  4853.      For example, for `INSERT ... SELECT' with no `ORDER BY', the
  4854.      `SELECT' may return rows in a different order (which will result
  4855.      in a row having different ranks, hence getting a different number
  4856.      in the `AUTO_INCREMENT' column), depending on the choices made by
  4857.      the optimizers on the master and slave. A query will be optimized
  4858.      differently on the master and slave only if:
  4859.  
  4860.         - The files used by the two queries are not exactly the same;
  4861.           for example, `OPTIMIZE TABLE' was run on the master tables
  4862.           and not on the slave tables. (To fix this, `OPTIMIZE TABLE',
  4863.           `ANALYZE TABLE', and `REPAIR TABLE' are written to the binary
  4864.           log as of MySQL 4.1.1).
  4865.  
  4866.         - The table is stored using a different storage engine on the
  4867.           master than on the slave. (It is possible to use different
  4868.           storage engines on the master and slave. For example, you can
  4869.           use `InnoDB' on the master, but `MyISAM' on the slave if the
  4870.           slave has less available disk space.)
  4871.  
  4872.         - MySQL buffer sizes (`key_buffer_size', and so on) are
  4873.           different on the master and slave.
  4874.  
  4875.         - The master and slave run different MySQL versions, and the
  4876.           optimizer code differs between these versions.
  4877.  
  4878.      This problem may also affect database restoration using
  4879.      `mysqlbinlog|mysql'.
  4880.  
  4881.      The easiest way to avoid this problem in all cases is to add an
  4882.      `ORDER BY' clause to such non-deterministic queries to ensure that
  4883.      the rows are always stored or modified in the same order.  In
  4884.      future MySQL versions, we will automatically add an `ORDER BY'
  4885.      clause when needed.
  4886.  
  4887.  
  4888. The following problems are known and will be fixed in due time:
  4889.  
  4890.    * Log filenames are based on the server hostname (if you don't
  4891.      specify a filename with the startup option). For now you have to
  4892.      use options like `--log-bin=OLD_HOST_NAME-bin' if you change your
  4893.      hostname to something else. Another option is to just rename the
  4894.      old files to reflect your hostname change. *Note Server options::.
  4895.  
  4896.    * `mysqlbinlog' will not delete temporary files left after a `LOAD
  4897.      DATA INFILE' command. *Note `mysqlbinlog': mysqlbinlog.
  4898.  
  4899.    * `RENAME' doesn't work with `TEMPORARY' tables or tables used in a
  4900.      `MERGE' table.
  4901.  
  4902.    * When using the `RPAD()' function in a query that has to be
  4903.      resolved by using a temporary table, all resulting strings will
  4904.      have rightmost spaces removed. This is an example of such a query:
  4905.  
  4906.           SELECT RPAD(t1.column1, 50, ' ') AS f2, RPAD(t2.column2, 50, ' ') AS f1
  4907.           FROM table1 as t1 LEFT JOIN table2 AS t2 ON t1.record=t2.joinID
  4908.           ORDER BY t2.record;
  4909.  
  4910.      The final result of this bug is that you will not be able to get
  4911.      spaces on the right side of the resulting values. The problem also
  4912.      occurs for any other string function that adds spaces to the right.
  4913.  
  4914.      The reason for this is due to the fact that `HEAP' tables, which
  4915.      are used first for temporary tables, are not capable of handling
  4916.      `VARCHAR' columns.
  4917.  
  4918.      This behavior exists in all versions of MySQL.  It will be fixed
  4919.      in one of the 4.1 series releases.
  4920.  
  4921.    * Due to the way table definition files are stored, you cannot use
  4922.      character 255 (`CHAR(255)') in table names, column names, or
  4923.      enumerations.  This is scheduled to be fixed in version 5.1 when
  4924.      we have new table definition format files.
  4925.  
  4926.    * When using `SET CHARACTER SET', you can't use translated
  4927.      characters in database, table, and column names.
  4928.  
  4929.    * You can't use `_' or `%' with `ESCAPE' in `LIKE ... ESCAPE'.
  4930.  
  4931.    * If you have a `DECIMAL' column in which the same number is stored
  4932.      in different formats (for example, `+01.00', `1.00', `01.00'),
  4933.      `GROUP BY' may regard each value as a different value.
  4934.  
  4935.    * You cannot build the server in another directory when using
  4936.      MIT-pthreads. Because this requires changes to MIT-pthreads, we
  4937.      are not likely to fix this. *Note MIT-pthreads::.
  4938.  
  4939.    * `BLOB' and `TEXT'values can't "reliably" be used in `GROUP BY' or
  4940.      `ORDER BY' or `DISTINCT'. Only the first `max_sort_length' bytes
  4941.      are used when comparing `BLOB' values in these cases.  The default
  4942.      value of `max_sort_length' value is 1024. It can be changed at
  4943.      server startup time.  As of MySQL 4.0.3, it can also be changed at
  4944.      runtime. For older versions, a workaround for most cases is to use
  4945.      a substring.  For example:
  4946.  
  4947.           SELECT DISTINCT LEFT(BLOB_COL,2048) FROM TBL_NAME;
  4948.  
  4949.    * Numeric calculations are done with `BIGINT' or `DOUBLE' (both are
  4950.      normally 64 bits long). Which precision you get depends on the
  4951.      function.  The general rule is that bit functions are done with
  4952.      `BIGINT' precision, `IF' and `ELT()' with `BIGINT' or `DOUBLE'
  4953.      precision, and the rest with `DOUBLE' precision.  You should try to
  4954.      avoid using unsigned long long values if they resolve to be bigger
  4955.      than 63 bits (9223372036854775807) for anything other than bit
  4956.      fields.  MySQL Server 4.0 has better `BIGINT' handling than 3.23.
  4957.  
  4958.    * All string columns, except `BLOB' and `TEXT' columns, automatically
  4959.      have all trailing spaces removed when retrieved. For `CHAR' types,
  4960.      this is okay. The bug is that in MySQL Server, `VARCHAR' columns
  4961.      are treated the same way.
  4962.  
  4963.    * You can have only up to 255 `ENUM' and `SET' columns in one table.
  4964.  
  4965.    * In `MIN()', `MAX()', and other aggregate functions, MySQL
  4966.      currently compares `ENUM' and `SET' columns by their string value
  4967.      rather than by the string's relative position in the set.
  4968.  
  4969.    * `mysqld_safe' redirects all messages from `mysqld' to the `mysqld'
  4970.      log.  One problem with this is that if you execute `mysqladmin
  4971.      refresh' to close and reopen the log, `stdout' and `stderr' are
  4972.      still redirected to the old log.  If you use `--log' extensively,
  4973.      you should edit `mysqld_safe' to log to `HOST_NAME.err' instead of
  4974.      `HOST_NAME.log' so that you can easily reclaim the space for the
  4975.      old log by deleting the old one and executing `mysqladmin refresh'.
  4976.  
  4977.    * In the `UPDATE' statement, columns are updated from left to right.
  4978.      If you refer to an updated column, you get the updated value
  4979.      instead of the original value. For example, the following
  4980.      statement increments `KEY' by `2', not `1':
  4981.  
  4982.           mysql> UPDATE TBL_NAME SET KEY=KEY+1,KEY=KEY+1;
  4983.  
  4984.    * You can refer to multiple temporary tables in the same query, but
  4985.      you cannot refer to any given temporary table more than once.  For
  4986.      example, the following doesn't work:
  4987.  
  4988.           mysql> SELECT * FROM temp_table, temp_table AS t2;
  4989.           ERROR 1137: Can't reopen table: 'temp_table'
  4990.  
  4991.    * The optimizer may handle `DISTINCT' differently when you are using
  4992.      "hidden" columns in a join than when you are not.  In a join,
  4993.      hidden columns are counted as part of the result (even if they are
  4994.      not shown), whereas in normal queries, hidden columns don't
  4995.      participate in the `DISTINCT' comparison.  We will probably change
  4996.      this in the future to never compare the hidden columns when
  4997.      executing `DISTINCT'.
  4998.  
  4999.      An example of this is:
  5000.  
  5001.           SELECT DISTINCT mp3id FROM band_downloads
  5002.                  WHERE userid = 9 ORDER BY id DESC;
  5003.  
  5004.      and
  5005.  
  5006.           SELECT DISTINCT band_downloads.mp3id
  5007.                  FROM band_downloads,band_mp3
  5008.                  WHERE band_downloads.userid = 9
  5009.                  AND band_mp3.id = band_downloads.mp3id
  5010.                  ORDER BY band_downloads.id DESC;
  5011.  
  5012.      In the second case, you might in MySQL Server 3.23.x get two
  5013.      identical rows in the result set (because the values in the hidden
  5014.      `id' column may differ).
  5015.  
  5016.      Note that this happens only for queries where you don't have the
  5017.      `ORDER BY' columns in the result.
  5018.  
  5019.    * Because MySQL Server allows you to work with table types that don't
  5020.      support transactions, and thus can't roll back data, some things
  5021.      behave a little differently in MySQL Server than in other SQL
  5022.      servers.  This is just to ensure that MySQL Server never needs to
  5023.      do a rollback for an SQL statement.  This may be a little awkward
  5024.      at times because column values must be checked in the application,
  5025.      but this will actually give you a nice speed increase because it
  5026.      allows MySQL Server to do some optimizations that otherwise would
  5027.      be very hard to do.
  5028.  
  5029.      If you set a column to an incorrect value, MySQL Server will,
  5030.      instead of doing a rollback, store the "best possible value" in
  5031.      the column. For information about how this occurs, see *Note
  5032.      Constraints::.
  5033.  
  5034.    * If you execute a `PROCEDURE' on a query that returns an empty set,
  5035.      in some cases the `PROCEDURE' will not transform the columns.
  5036.  
  5037.    * Creation of a table of type `MERGE' doesn't check whether the
  5038.      underlying tables are of compatible types.
  5039.  
  5040.    * If you use `ALTER TABLE' first to add a `UNIQUE' index to a table
  5041.      used in a `MERGE' table and then to add a normal index on the
  5042.      `MERGE' table, the key order will be different for the tables if
  5043.      there was an old key that was not unique in the table. This is
  5044.      because `ALTER TABLE' puts `UNIQUE' indexes before normal indexes
  5045.      to be able to detect duplicate keys as early as possible.
  5046.  
  5047. The following are known bugs in earlier versions of MySQL:
  5048.  
  5049.    * In the following case you can get a core dump:
  5050.  
  5051.         - Delayed insert handler has pending inserts to a table.
  5052.  
  5053.         - `LOCK TABLE' with `WRITE'.
  5054.  
  5055.         - `FLUSH TABLES'.
  5056.  
  5057.    * Before MySQL Server 3.23.2, an `UPDATE' that updated a key with a
  5058.      `WHERE' on the same key may have failed because the key was used to
  5059.      search for records and the same row may have been found multiple
  5060.      times:
  5061.  
  5062.           UPDATE TBL_NAME SET KEY=KEY+1 WHERE KEY > 100;
  5063.  
  5064.      A workaround is to use:
  5065.  
  5066.           UPDATE TBL_NAME SET KEY=KEY+1 WHERE KEY+0 > 100;
  5067.  
  5068.      This will work because MySQL Server will not use an index on
  5069.      expressions in the `WHERE' clause.
  5070.  
  5071.    * Before MySQL Server 3.23, all numeric types were treated as
  5072.      fixed-point fields. That means that you had to specify how many
  5073.      decimals a floating-point field should have. All results were
  5074.      returned with the correct number of decimals.
  5075.  
  5076. For information about platform-specific bugs, see the installation and
  5077. porting instructions in *Note Operating System Specific Notes:: and
  5078. *Note Porting::.
  5079.  
  5080. Installing MySQL
  5081. ****************
  5082.  
  5083. This chapter describes how to obtain and install MySQL:
  5084.  
  5085.   1. *Determine whether your platform is supported.*  Please note that
  5086.      not all supported systems are equally good for running MySQL on
  5087.      them.  On some it is much more robust and efficient than others.
  5088.      See *Note Which OS:: for details.
  5089.  
  5090.   2. *Choose which distribution to install.*  Several versions of MySQL
  5091.      are available, and most are available in several distribution
  5092.      formats.  You can choose from pre-packaged distributions
  5093.      containing binary (precompiled) programs or source code.  When in
  5094.      doubt, use a binary distribution.  We also provide public access
  5095.      to our current source tree for those who want to see our most
  5096.      recent developments and help us test new code.  To determine which
  5097.      version and type of distribution you should use, see *Note Which
  5098.      version::.
  5099.  
  5100.   3. *Download the distribution that you want to install.* For a list
  5101.      of sites from which you can obtain MySQL, see *Note Getting MySQL:
  5102.      Getting MySQL.  You can verify the integrity of the distribution
  5103.      using the instructions in *Note Verifying Package Integrity::.
  5104.  
  5105.   4. *Install the distribution.*  To install MySQL from a binary
  5106.      distribution, use the instructions in *Note Quick Standard
  5107.      Installation::.  To install MySQL from a source distribution or
  5108.      from the current development source tree, use the instructions in
  5109.      *Note Installing source::.
  5110.  
  5111.      *Note*: If you plan to upgrade an existing version of MySQL to a
  5112.      newer version rather than installing MySQL for the first time, see
  5113.      *Note Upgrade:: for information about upgrade procedures and about
  5114.      issues that you should consider before upgrading.
  5115.  
  5116.      If you encounter installation difficulties, see *Note Operating
  5117.      System Specific Notes:: for information on solving problems for
  5118.      particular platforms.
  5119.  
  5120.   5. *Perform any necessary post-installation setup.* After installing
  5121.      MySQL, read *Note Post-installation::.  This section contains
  5122.      important information about making sure the MySQL server is
  5123.      working properly. It also describes how to secure the initial
  5124.      MySQL user accounts, _which have no passwords_ until you assign
  5125.      passwords.  The section applies whether you install MySQL using a
  5126.      binary or source distribution.
  5127.  
  5128.   6. If you want to run the MySQL benchmark scripts, Perl support for
  5129.      MySQL must be available.  *Note Perl support::.
  5130.  
  5131.  
  5132. General Installation Issues
  5133. ===========================
  5134.  
  5135. Before installing MySQL, you should do the following:
  5136.  
  5137.   1. Determine whether or not MySQL runs on your platform.
  5138.  
  5139.   2. Choose a distribution to install.
  5140.  
  5141.   3. Download the distribution and verify its integrity.
  5142.  
  5143.  
  5144. This section contains the information necessary to carry out these
  5145. steps.  After doing so, you can use the instructions in later sections
  5146. of the chapter to install the distribution that you choose.
  5147.  
  5148. Operating Systems Supported by MySQL
  5149. ------------------------------------
  5150.  
  5151. This section lists the operating systems on which you can expect to be
  5152. able to run MySQL.
  5153.  
  5154. We use GNU Autoconf, so it is possible to port MySQL to all modern
  5155. systems that have a C++ compiler and a working implementation of POSIX
  5156. threads.  (Thread support is needed for the server. To compile only the
  5157. client code, the only requirement is a C++ compiler.) We use and
  5158. develop the software ourselves primarily on Linux (SuSE and Red Hat),
  5159. FreeBSD, and Sun Solaris (Versions 8 and 9).
  5160.  
  5161. MySQL has been reported to compile successfully on the following
  5162. combinations of operating system and thread package.  Note that for many
  5163. operating systems, native thread support works only in the latest
  5164. versions.
  5165.  
  5166.    * AIX 4.x, 5.x with native threads.  *Note IBM-AIX::.
  5167.  
  5168.    * Amiga.
  5169.  
  5170.    * BSDI 2.x with the MIT-pthreads package.  *Note BSDI::.
  5171.  
  5172.    * BSDI 3.0, 3.1 and 4.x with native threads.  *Note BSDI::.
  5173.  
  5174.    * Digital Unix 4.x with native threads.  *Note Alpha-DEC-UNIX::.
  5175.  
  5176.    * FreeBSD 2.x with the MIT-pthreads package.  *Note FreeBSD::.
  5177.  
  5178.    * FreeBSD 3.x and 4.x with native threads.  *Note FreeBSD::.
  5179.  
  5180.    * FreeBSD 4.x with LinuxThreads.  *Note FreeBSD::.
  5181.  
  5182.    * HP-UX 10.20 with the DCE threads or the MIT-pthreads package.
  5183.      *Note HP-UX 10.20::.
  5184.  
  5185.    * HP-UX 11.x with the native threads.  *Note HP-UX 11.x::.
  5186.  
  5187.    * Linux 2.0+ with LinuxThreads 0.7.1+ or `glibc' 2.0.7+ for various
  5188.      CPU architectures.  *Note Linux::.
  5189.  
  5190.    * Mac OS X.  *Note Mac OS X::.
  5191.  
  5192.    * NetBSD 1.3/1.4 Intel and NetBSD 1.3 Alpha (requires GNU make).
  5193.      *Note NetBSD::.
  5194.  
  5195.    * Novell NetWare 6.0.  *Note NetWare installation::.
  5196.  
  5197.    * OpenBSD > 2.5 with native threads. OpenBSD < 2.5 with the
  5198.      MIT-pthreads package.  *Note OpenBSD::.
  5199.  
  5200.    * OS/2 Warp 3, FixPack 29 and OS/2 Warp 4, FixPack 4.  *Note OS/2::.
  5201.  
  5202.    * SCO OpenServer with a recent port of the FSU Pthreads package.
  5203.      *Note SCO::.
  5204.  
  5205.    * SCO UnixWare 7.1.x.  *Note SCO UnixWare::.
  5206.  
  5207.    * SGI Irix 6.x with native threads.  *Note SGI-Irix::.
  5208.  
  5209.    * Solaris 2.5 and above with native threads on SPARC and x86.  *Note
  5210.      Solaris::.
  5211.  
  5212.    * SunOS 4.x with the MIT-pthreads package.  *Note Solaris::.
  5213.  
  5214.    * Tru64 Unix.  *Note Alpha-DEC-UNIX::.
  5215.  
  5216.    * Windows 9x, Me, NT, 2000, and XP.  *Note Windows installation::.
  5217.  
  5218. Not all platforms are equally well-suited for running MySQL. How well a
  5219. certain platform is suited for a high-load mission-critical MySQL
  5220. server is determined by the following factors:
  5221.  
  5222.    * General stability of the thread library. A platform may have an
  5223.      excellent reputation otherwise, but MySQL will be only as stable
  5224.      as the thread library if that library is unstable in the code that
  5225.      is called by MySQL, even if everything else is perfect.
  5226.  
  5227.    * The capability of the kernel and the thread library to take
  5228.      advantage of symmetric multi-processor (SMP) systems. In other
  5229.      words, when a process creates a thread, it should be possible for
  5230.      that thread to run on a different CPU than the original process.
  5231.  
  5232.    * The capability of the kernel and the thread library to run many
  5233.      threads that acquire and release a mutex over a short critical
  5234.      region frequently without excessive context switches. If the
  5235.      implementation of `pthread_mutex_lock()' is too anxious to yield
  5236.      CPU time, this will hurt MySQL tremendously. If this issue is not
  5237.      taken care of, adding extra CPUs will actually make MySQL slower.
  5238.  
  5239.    * General filesystem stability and performance.
  5240.  
  5241.    * If your tables are big, the ability of the filesystem to deal with
  5242.      large files at all and to deal with them efficiently.
  5243.  
  5244.    * Our level of expertise here at MySQL AB with the platform. If we
  5245.      know a platform well, we enable platform-specific optimizations
  5246.      and fixes at compile time. We can also provide advice on
  5247.      configuring your system optimally for MySQL.
  5248.  
  5249.    * The amount of testing we have done internally for similar
  5250.      configurations.
  5251.  
  5252.    * The number of users that have successfully run MySQL on the
  5253.      platform in similar configurations. If this number is high, the
  5254.      chances of encountering platform-specific surprises are much
  5255.      smaller.
  5256.  
  5257. Based on the preceding criteria, the best platforms for running MySQL
  5258. at this point are x86 with SuSE Linux using a 2.4 kernel, and ReiserFS
  5259. (or any similar Linux distribution) and SPARC with Solaris (2.7-9).
  5260. FreeBSD comes third, but we really hope it will join the top club once
  5261. the thread library is improved. We also hope that at some point we will
  5262. be able to include into the top category all other platforms on which
  5263. MySQL currently compiles and runs okay, but not quite with the same
  5264. level of stability and performance.  This will require some effort on
  5265. our part in cooperation with the developers of the operating system and
  5266. library components that MySQL depends on. If you are interested in
  5267. improving one of those components, are in a position to influence its
  5268. development, and need more detailed instructions on what MySQL needs to
  5269. run better, send an email message to the MySQL `internals' mailing list.
  5270. *Note Mailing-list::.
  5271.  
  5272. Please note that the purpose of the preceding comparison is not to say
  5273. that one operating system is better or worse than another in general.
  5274. We are talking only about choosing an OS for the specific purpose of
  5275. running MySQL.  With this in mind, the result of this comparison would
  5276. be different if we considered more factors. In some cases, the reason
  5277. one OS is better than the other could simply be that we have been able
  5278. to put more effort into testing and optimizing for a particular
  5279. platform.  We are just stating our observations to help you decide
  5280. which platform to use for running MySQL.
  5281.  
  5282. Choosing Which MySQL Distribution to Install
  5283. --------------------------------------------
  5284.  
  5285. When preparing to install MySQL, you should decide which version to
  5286. use.  MySQL development occurs in several release series, and you can
  5287. pick the one that best fits your needs.  After deciding which version
  5288. to install, you can choose a distribution format.  Releases are
  5289. available in binary or source format.
  5290.  
  5291. Choosing Which Version of MySQL to Install
  5292. ..........................................
  5293.  
  5294. The first decision to make is whether you want to use a production
  5295. (stable) release or a development release.  In the MySQL development
  5296. process, multiple release series co-exist, each at a different stage of
  5297. maturity:
  5298.  
  5299.    * MySQL 5.0 is the newest development release series and is under
  5300.      very active development for new features. Until recently it was
  5301.      available only in preview form from the BitKeeper source
  5302.      repository. An early alpha release has now been issued to allow
  5303.      more widespread testing.
  5304.  
  5305.    * MySQL 4.1 is a development release series to which major new
  5306.      features have been added. It is still at beta status. Sources and
  5307.      binaries are available for use and testing on development systems.
  5308.  
  5309.    * MySQL 4.0 is the current stable (production-quality) release
  5310.      series.  New releases are issued for bugfixes. No new features are
  5311.      added that could diminish the code stability.
  5312.  
  5313.    * MySQL 3.23 is the old stable (production-quality) release series.
  5314.      This series is retired, so new releases are issued only to fix
  5315.      critical bugs.
  5316.  
  5317.  
  5318. We don't believe in a complete freeze, as this also leaves out bugfixes
  5319. and things that "must be done."  "Somewhat frozen" means that we may add
  5320. small things that "almost surely will not affect anything that's already
  5321. working." Naturally, relevant bugfixes from an earlier series propagate
  5322. to later series.
  5323.  
  5324. Normally, if you are beginning to use MySQL for the first time or trying
  5325. to port it to some system for which there is no binary distribution, we
  5326. recommend going with the production release series. Currently this is
  5327. MySQL 4.0.  All MySQL releases, even those from development series, are
  5328. checked with the MySQL benchmarks and an extensive test suite before
  5329. being issued.
  5330.  
  5331. If you are running an old system and want to upgrade, but don't want to
  5332. take the chance of having a non-seamless upgrade, you should upgrade to
  5333. the latest version in the same release series you are using (where only
  5334. the last part of the version number is newer than yours).  We have tried
  5335. to fix only fatal bugs and make small, relatively safe changes to that
  5336. version.
  5337.  
  5338. If you want to use new features not present in the production release
  5339. series, you can use a version from a development series. Note that
  5340. development releases are not as stable as production releases.
  5341.  
  5342. If you want to use the very latest sources containing all current
  5343. patches and bugfixes, you can use one of our BitKeeper repositories.
  5344. These are not "releases" as such, but are available as previews of the
  5345. code on which future releases will be based.
  5346.  
  5347. The MySQL naming scheme uses release names that consist of three
  5348. numbers and a suffix; for example, `mysql-4.1.2-alpha'.  The numbers
  5349. within the release name are interpreted like this:
  5350.  
  5351.    * The first number (`4') is the major version and also describes the
  5352.      file format.  All Version 4 releases have the same file format.
  5353.  
  5354.    * The second number (`1') is the release level.  Taken together, the
  5355.      major version and release level constitute the release series
  5356.      number.
  5357.  
  5358.    * The third number (`2') is the version number within the release
  5359.      series.  This is incremented for each new release.  Usually you
  5360.      want the latest version for the series you have chosen.
  5361.  
  5362.  
  5363. For each minor update, the last number in the version string is
  5364. incremented.  When there are major new features or minor
  5365. incompatibilities with previous versions, the second number in the
  5366. version string is incremented.  When the file format changes, the first
  5367. number is increased.
  5368.  
  5369. Release names also include a suffix to indicates the stability level of
  5370. the release.  Releases within a series progress through a set of
  5371. suffixes to indicate how the stability level improves.  The possible
  5372. suffixes are:
  5373.  
  5374.    * `alpha' indicates that the release contains some large section of
  5375.      new code that hasn't been 100% tested.  Known bugs (usually there
  5376.      are none) should be documented in the News section.  *Note News::.
  5377.      There are also new commands and extensions in most alpha
  5378.      releases.  Active development that may involve major code changes
  5379.      can occur in an alpha release, but everything will be tested
  5380.      before issuing a release.  For this reason, there should be no
  5381.      known bugs in any MySQL release.
  5382.  
  5383.    * `beta' means that all new code has been tested.  No major new
  5384.      features that could cause corruption in old code are added.  There
  5385.      should be no known bugs.  A version changes from alpha to beta
  5386.      when there haven't been any reported fatal bugs within an alpha
  5387.      version for at least a month and we have no plans to add any
  5388.      features that could make any old command unreliable.
  5389.  
  5390.    * `gamma' is a beta that has been around a while and seems to work
  5391.      fine.  Only minor fixes are added.  This is what many other
  5392.      companies call a release.
  5393.  
  5394.    * If there is no suffix, it means that the version has been run for a
  5395.      while at many different sites with no reports of bugs other than
  5396.      platform-specific bugs.  Only critical bugfixes are applied to the
  5397.      release. This is what we call a production (stable) release.
  5398.  
  5399. MySQL uses a naming scheme that is slightly different from most other
  5400. products.  In general, it's relatively safe to use any version that has
  5401. been out for a couple of weeks without being replaced with a new
  5402. version within the release series.
  5403.  
  5404. All releases of MySQL are run through our standard tests and benchmarks
  5405. to ensure that they are relatively safe to use.  Because the standard
  5406. tests are extended over time to check for all previously found bugs,
  5407. the test suite keeps getting better.
  5408.  
  5409. All releases have been tested at least with:
  5410.  
  5411. An internal test suite
  5412.      The `mysql-test' directory contains an extensive set of test cases.
  5413.      We run these tests for virtually every server binary.  See *Note
  5414.      MySQL test suite:: for more information about this test suite.
  5415.  
  5416. The MySQL benchmark suite
  5417.      This suite runs a range of common queries.  It is also a test to
  5418.      see whether the latest batch of optimizations actually made the
  5419.      code faster.  *Note MySQL Benchmarks::.
  5420.  
  5421. The `crash-me' test
  5422.      This test tries to determine what features the database supports
  5423.      and what its capabilities and limitations are.  *Note MySQL
  5424.      Benchmarks::.
  5425.  
  5426. Another test is that we use the newest MySQL version in our internal
  5427. production environment, on at least one machine.  We have more than
  5428. 100GB of data to work with.
  5429.  
  5430. Choosing a Distribution Format
  5431. ..............................
  5432.  
  5433. After choosing which version of MySQL to install, you should decide
  5434. whether to use a binary distribution or a source distribution.  In most
  5435. cases, you should probably use a binary distribution, if one exists for
  5436. your platform. Binary distributions are available in native format for
  5437. many platforms, such as RPM files for Linux or DMG package installers
  5438. for Mac OS X. Distributions also are available as Zip archives or
  5439. compressed `tar' files.
  5440.  
  5441. Reasons to choose a binary distribution include the following:
  5442.  
  5443.    * Binary distributions generally are easier to install than source
  5444.      distributions.
  5445.  
  5446.    * To satisfy different user requirements, we provide two different
  5447.      binary versions: one compiled with the non-transactional storage
  5448.      engines (a small, fast binary), and one configured with the most
  5449.      important extended options like transaction-safe tables.  Both
  5450.      versions are compiled from the same source distribution.  All
  5451.      native MySQL clients can connect to servers from either MySQL
  5452.      version.
  5453.  
  5454.      The extended MySQL binary distribution is marked with the `-max'
  5455.      suffix and is configured with the same options as `mysqld-max'.
  5456.      *Note `mysqld-max': mysqld-max.
  5457.  
  5458.      If you want to use the `MySQL-Max' RPM, you must first install the
  5459.      standard `MySQL-server' RPM.
  5460.  
  5461.  
  5462. Under some circumstances, you probably will be better off installing
  5463. MySQL from a source distribution:
  5464.  
  5465.    * You want to install MySQL at some explicit location.  The standard
  5466.      binary distributions are "ready to run" at any place, but you may
  5467.      want to have even more flexibility to place MySQL components where
  5468.      you want.
  5469.  
  5470.    * You want to configure `mysqld' with some extra features that are
  5471.      not included in the standard binary distributions.  Here is a list
  5472.      of the most common extra options that you may want to use:
  5473.  
  5474.         * `--with-innodb' (default for MySQL 4.0 and up)
  5475.  
  5476.         * `--with-berkeley-db' (not available on all platforms)
  5477.  
  5478.         * `--with-raid'
  5479.  
  5480.         * `--with-libwrap'
  5481.  
  5482.         * `--with-named-z-libs' (this is done for some of the binaries)
  5483.  
  5484.         * `--with-debug[=FULL]'
  5485.  
  5486.    * You want to configure `mysqld' without some features that are
  5487.      included in the standard binary distributions. For example,
  5488.      distributions normally are compiled with support for all character
  5489.      sets. If you want a smaller MySQL server, you can recompile it
  5490.      with support for only the character sets you need.
  5491.  
  5492.    * You have a special compiler (such as `pgcc') or want to use
  5493.      compiler options that are better optimized for your processor.
  5494.      Binary distributions are compiled with options that should work on
  5495.      a variety of processors from the same processor family.
  5496.  
  5497.    * You want to use the latest sources from one of the BitKeeper
  5498.      repositories to have access to all current bugfixes. For example,
  5499.      if you have found a bug and reported it to the MySQL development
  5500.      team, the bugfix will be committed to the source repository and you
  5501.      can access it there.  The bugfix will not appear in a release until
  5502.      a release actually is issued.
  5503.  
  5504.    * You want to read (or modify) the C and C++ code that makes up
  5505.      MySQL. For this purpose, you should get a source distribution,
  5506.      because the source code is always the ultimate manual.
  5507.  
  5508.    * Source distributions contain more tests and examples than binary
  5509.      distributions.
  5510.  
  5511.  
  5512. How and When Updates Are Released
  5513. .................................
  5514.  
  5515. MySQL is evolving quite rapidly here at MySQL AB and we want to share
  5516. new developments with other MySQL users.  We try to make a release when
  5517. we have very useful features that others seem to have a need for.
  5518.  
  5519. We also try to help out users who request features that are easy to
  5520. implement.  We take note of what our licensed users want to have, and
  5521. we especially take note of what our extended email-supported customers
  5522. want and try to help them out.
  5523.  
  5524. No one has to download a new release.  The News section will tell you if
  5525. the new release has something you really want.  *Note News::.
  5526.  
  5527. We use the following policy when updating MySQL:
  5528.  
  5529.    * Releases are issued within each series. For each release, the last
  5530.      number in the version is one more than the previous release within
  5531.      the same series.
  5532.  
  5533.    * Production (stable) releases are meant to appear about 1-2 times a
  5534.      year.  However, if small bugs are found, a release with only
  5535.      bugfixes will be issued.
  5536.  
  5537.    * Working releases/bugfixes to old releases are meant to appear about
  5538.      every 4-8 weeks.
  5539.  
  5540.    * Binary distributions for some platforms are made by us for major
  5541.      releases.  Other people may make binary distributions for other
  5542.      systems, but probably less frequently.
  5543.  
  5544.    * We make fixes available as soon as we have identified and corrected
  5545.      small or non-critical but annoying bugs. The fixes are available
  5546.      immediately from our public BitKeeper repositories, and will be
  5547.      included in the next release.
  5548.  
  5549.    * If by any chance a fatal bug is found in a release, we will make a
  5550.      new release as soon as possible.  (We would like other companies
  5551.      to do this, too!)
  5552.  
  5553. Release Philosophy--No Known Bugs in Releases
  5554. .............................................
  5555.  
  5556. We put a lot of time and effort into making our releases bug-free.  To
  5557. our knowledge, we have not released a single MySQL version with any
  5558. _known_ "fatal" repeatable bugs.  (A "fatal" bug is something that
  5559. crashes MySQL under normal usage, produces incorrect answers for normal
  5560. queries, or has a security problem.)
  5561.  
  5562. We have documented all open problems, bugs, and issues that are
  5563. dependent on design decisions.  *Note Bugs::.
  5564.  
  5565. Our aim is to fix everything that is fixable without risk of making a
  5566. stable MySQL version less stable. In certain cases, this means we can
  5567. fix an issue in the development versions, but not in the stable
  5568. (production) version. Naturally, we document such issues so that users
  5569. are aware of them.
  5570.  
  5571. Here is a description of how our build process works:
  5572.    * We monitor bugs from our customer support list, the bugs database
  5573.      at `http://bugs.mysql.com/', and the MySQL external mailing lists.
  5574.  
  5575.    * All reported bugs for live versions are entered into the bugs
  5576.      database.
  5577.  
  5578.    * When we fix a bug, we always try to make a test case for it and
  5579.      include it into our test system to ensure that the bug will never
  5580.      recur without being detected. (About 90% of all fixed bugs have a
  5581.      test case.)
  5582.  
  5583.    * We create test cases for all new features we add to MySQL.
  5584.  
  5585.    * Before we start to build a new MySQL release, we ensure that all
  5586.      reported repeatable bugs for the MySQL version (3.23.x, 4.0.x, etc)
  5587.      are fixed.  If something is impossible to fix (due to some internal
  5588.      design decision in MySQL), we document this in the manual.  *Note
  5589.      Bugs::.
  5590.  
  5591.    * We do a build on all platforms for which we support binaries (15+
  5592.      platforms) and run our test suite and benchmark suite on all of
  5593.      them.
  5594.  
  5595.    * We will not publish a binary for a platform for which the test or
  5596.      benchmark suite fails.  If the problem is due to a general error
  5597.      in the source, we fix it and do the build plus tests on all
  5598.      systems again from scratch.
  5599.  
  5600.    * The build and test process takes 2-3 days.  If we receive a report
  5601.      regarding a fatal bug during this process (for example, one that
  5602.      causes a core dump), we fix the problem and restart the build
  5603.      process.
  5604.  
  5605.    * After publishing the binaries on `http://dev.mysql.com/', we send
  5606.      out an announcement message to the `mysql' and `announce' mailing
  5607.      lists.  *Note Mailing-list::.  The announcement message contains a
  5608.      list of all changes to the release and any known problems with the
  5609.      release.  The Known Problems section in the release notes has been
  5610.      needed for only a handful of releases.
  5611.  
  5612.    * To quickly give our users access to the latest MySQL features, we
  5613.      do a new MySQL release every 4-8 weeks.  Source code snapshots are
  5614.      built daily and are available at
  5615.      `http://downloads.mysql.com/snapshots.php'.
  5616.  
  5617.    * If, despite our best efforts, we get any bug reports after the
  5618.      release is done that there was something critically wrong with the
  5619.      build on a specific platform, we will fix it at once and build a
  5620.      new `'a'' release for that platform. Thanks to our large user
  5621.      base, problems are found quickly.
  5622.  
  5623.    * Our track record for making good releases is quite good.  In the
  5624.      last 150 releases, we had to do a new build for fewer than 10
  5625.      releases. In three of these cases, the bug was a faulty `glibc'
  5626.      library on one of our build machines that took us a long time to
  5627.      track down.
  5628.  
  5629. MySQL Binaries Compiled by MySQL AB
  5630. ...................................
  5631.  
  5632. As a service of MySQL AB, we provide a set of binary distributions of
  5633. MySQL that are compiled on systems at our site or on systems where
  5634. supporters of MySQL kindly have given us access to their machines.
  5635.  
  5636. In addition to the binaries provided in platform-specific package
  5637. formats, we offer binary distributions for a number of platforms in the
  5638. form of compressed `tar' files (`.tar.gz' files).  *Note Quick Standard
  5639. Installation::.
  5640.  
  5641. For Windows distributions, see *Note Windows installation::.
  5642.  
  5643. These distributions are generated using the script
  5644. `Build-tools/Do-compile', which compiles the source code and creates
  5645. the binary `tar.gz' archive using `scripts/make_binary_distribution'.
  5646.  
  5647. These binaries are configured and built with the following compilers and
  5648. options. This information can also be obtained by looking at the
  5649. variables `COMP_ENV_INFO' and `CONFIGURE_LINE' inside the script
  5650. `bin/mysqlbug' of every binary `tar' file distribution.
  5651.  
  5652. The following binaries are built on MySQL AB development systems:
  5653.  
  5654. Linux 2.4.xx x86 with `gcc' 2.95.3:
  5655.      `CFLAGS="-O2 -mcpu=pentiumpro" CXX=gcc CXXFLAGS="-O2
  5656.      -mcpu=pentiumpro -felide-constructors" ./configure
  5657.      --prefix=/usr/local/mysql --with-extra-charsets=complex
  5658.      --enable-thread-safe-client --enable-local-infile
  5659.      --enable-assembler --disable-shared
  5660.      --with-client-ldflags=-all-static
  5661.      --with-mysqld-ldflags=-all-static'
  5662.  
  5663. Linux 2.4.x x86 with `icc' (Intel C++ Compiler 8.0):
  5664.      `CC=icc CXX=icc CFLAGS="-O3 -unroll2 -ip -mp -no-gcc -restrict"
  5665.      CXXFLAGS="-O3 -unroll2 -ip -mp -no-gcc -restrict" ./configure
  5666.      --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data
  5667.      --libexecdir=/usr/local/mysql/bin --with-extra-charsets=complex
  5668.      --enable-thread-safe-client --enable-local-infile
  5669.      --enable-assembler --disable-shared
  5670.      --with-client-ldflags=-all-static
  5671.      --with-mysqld-ldflags=-all-static --with-embedded-server
  5672.      --with-innodb'
  5673.  
  5674. Linux 2.4.xx Intel Itanium 2 with `ecc' (Intel C++ Itanium Compiler 7.0):
  5675.      `CC=ecc CFLAGS="-O2 -tpp2 -ip -nolib_inline" CXX=ecc CXXFLAGS="-O2
  5676.      -tpp2 -ip -nolib_inline" ./configure --prefix=/usr/local/mysql
  5677.      --with-extra-charsets=complex --enable-thread-safe-client
  5678.      --enable-local-infile'
  5679.  
  5680. Linux 2.4.xx Intel Itanium with `ecc' (Intel C++ Itanium Compiler 7.0):
  5681.      `CC=ecc CFLAGS=-tpp1 CXX=ecc CXXFLAGS=-tpp1 ./configure
  5682.      --prefix=/usr/local/mysql --with-extra-charsets=complex
  5683.      --enable-thread-safe-client --enable-local-infile'
  5684.  
  5685. Linux 2.4.xx alpha with `ccc' (Compaq C V6.2-505 / Compaq C++ V6.3-006):
  5686.      `CC=ccc CFLAGS="-fast -arch generic" CXX=cxx CXXFLAGS="-fast -arch
  5687.      generic -noexceptions -nortti" ./configure
  5688.      --prefix=/usr/local/mysql --with-extra-charsets=complex
  5689.      --enable-thread-safe-client --enable-local-infile
  5690.      --with-mysqld-ldflags=-non_shared
  5691.      --with-client-ldflags=-non_shared --disable-shared'
  5692.  
  5693. Linux 2.x.xx ppc with `gcc' 2.95.4:
  5694.      `CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-O3
  5695.      -fno-omit-frame-pointer -felide-constructors -fno-exceptions
  5696.      -fno-rtti" ./configure --prefix=/usr/local/mysql
  5697.      --localstatedir=/usr/local/mysql/data
  5698.      --libexecdir=/usr/local/mysql/bin --with-extra-charsets=complex
  5699.      --enable-thread-safe-client --enable-local-infile
  5700.      --disable-shared --with-embedded-server --with-innodb'
  5701.  
  5702. Linux 2.4.xx s390 with `gcc' 2.95.3:
  5703.      `CFLAGS="-O2" CXX=gcc CXXFLAGS="-O2 -felide-constructors"
  5704.      ./configure --prefix=/usr/local/mysql
  5705.      --with-extra-charsets=complex --enable-thread-safe-client
  5706.      --enable-local-infile --disable-shared
  5707.      --with-client-ldflags=-all-static
  5708.      --with-mysqld-ldflags=-all-static'
  5709.  
  5710. Linux 2.4.xx x86_64 (AMD64) with `gcc' 3.2.1:
  5711.      `CXX=gcc ./configure --prefix=/usr/local/mysql
  5712.      --with-extra-charsets=complex --enable-thread-safe-client
  5713.      --enable-local-infile  --disable-shared'
  5714.  
  5715. Sun Solaris 8 x86 with `gcc' 3.2.3:
  5716.      `CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-O3
  5717.      -fno-omit-frame-pointer -felide-constructors -fno-exceptions
  5718.      -fno-rtti" ./configure --prefix=/usr/local/mysql
  5719.      --localstatedir=/usr/local/mysql/data
  5720.      --libexecdir=/usr/local/mysql/bin --with-extra-charsets=complex
  5721.      --enable-thread-safe-client --enable-local-infile
  5722.      --disable-shared --with-innodb'
  5723.  
  5724. Sun Solaris 8 SPARC with `gcc' 3.2:
  5725.      `CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-O3
  5726.      -fno-omit-frame-pointer -felide-constructors -fno-exceptions
  5727.      -fno-rtti" ./configure --prefix=/usr/local/mysql
  5728.      --with-extra-charsets=complex --enable-thread-safe-client
  5729.      --enable-local-infile --enable-assembler --with-named-z-libs=no
  5730.      --with-named-curses-libs=-lcurses --disable-shared'
  5731.  
  5732. Sun Solaris 8 SPARC 64-bit with `gcc' 3.2:
  5733.      `CC=gcc CFLAGS="-O3 -m64 -fno-omit-frame-pointer" CXX=gcc
  5734.      CXXFLAGS="-O3 -m64 -fno-omit-frame-pointer -felide-constructors
  5735.      -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql
  5736.      --with-extra-charsets=complex --enable-thread-safe-client
  5737.      --enable-local-infile --with-named-z-libs=no
  5738.      --with-named-curses-libs=-lcurses --disable-shared'
  5739.  
  5740. Sun Solaris 9 SPARC with `gcc' 2.95.3:
  5741.      `CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-O3
  5742.      -fno-omit-frame-pointer -felide-constructors -fno-exceptions
  5743.      -fno-rtti" ./configure --prefix=/usr/local/mysql
  5744.      --with-extra-charsets=complex --enable-thread-safe-client
  5745.      --enable-local-infile --enable-assembler
  5746.      --with-named-curses-libs=-lcurses --disable-shared'
  5747.  
  5748. Sun Solaris 9 SPARC with `cc-5.0' (Sun Forte 5.0):
  5749.      `CC=cc-5.0 CXX=CC ASFLAGS="-xarch=v9" CFLAGS="-Xa -xstrconst -mt
  5750.      -D_FORTEC_ -xarch=v9" CXXFLAGS="-noex -mt -D_FORTEC_ -xarch=v9"
  5751.      ./configure --prefix=/usr/local/mysql
  5752.      --with-extra-charsets=complex --enable-thread-safe-client
  5753.      --enable-local-infile --enable-assembler --with-named-z-libs=no
  5754.      --enable-thread-safe-client --disable-shared'
  5755.  
  5756. IBM AIX 4.3.2 ppc with `gcc' 3.2.3:
  5757.      `CFLAGS="-O2 -mcpu=powerpc -Wa,-many " CXX=gcc CXXFLAGS="-O2
  5758.      -mcpu=powerpc -Wa,-many  -felide-constructors -fno-exceptions
  5759.      -fno-rtti" ./configure --prefix=/usr/local/mysql
  5760.      --with-extra-charsets=complex --enable-thread-safe-client
  5761.      --enable-local-infile --with-named-z-libs=no --disable-shared'
  5762.  
  5763. IBM AIX 4.3.3 ppc with `xlC_r' (IBM Visual Age C/C++ 6.0):
  5764.      `CC=xlc_r CFLAGS="-ma -O2 -qstrict -qoptimize=2 -qmaxmem=8192"
  5765.      CXX=xlC_r CXXFLAGS ="-ma -O2 -qstrict -qoptimize=2 -qmaxmem=8192"
  5766.      ./configure --prefix=/usr/local/mysql
  5767.      --localstatedir=/usr/local/mysql/data
  5768.      --libexecdir=/usr/local/mysql/bin --with-extra-charsets=complex
  5769.      --enable-thread-safe-client --enable-local-infile
  5770.      --with-named-z-libs=no --disable-shared --with-innodb'
  5771.  
  5772. IBM AIX 5.1.0 ppc with `gcc' 3.3:
  5773.      `CFLAGS="-O2 -mcpu=powerpc -Wa,-many" CXX=gcc CXXFLAGS="-O2
  5774.      -mcpu=powerpc -Wa,-many  -felide-constructors -fno-exceptions
  5775.      -fno-rtti" ./configure --prefix=/usr/local/mysql
  5776.      --with-extra-charsets=complex --enable-thread-safe-client
  5777.      --enable-local-infile --with-named-z-libs=no --disable-shared'
  5778.  
  5779. IBM AIX 5.2.0 ppc with `xlC_r' (IBM Visual Age C/C++ 6.0):
  5780.      `CC=xlc_r CFLAGS="-ma -O2 -qstrict -qoptimize=2 -qmaxmem=8192"
  5781.      CXX=xlC_r CXXFLAGS="-ma -O2 -qstrict -qoptimize=2 -qmaxmem=8192"
  5782.      ./configure --prefix=/usr/local/mysql
  5783.      --localstatedir=/usr/local/mysql/data
  5784.      --libexecdir=/usr/local/mysql/bin --with-extra-charsets=complex
  5785.      --enable-thread-safe-client --enable-local-infile
  5786.      --with-named-z-libs=no --disable-shared --with-embedded-server
  5787.      --with-innodb'
  5788.  
  5789. HP-UX 10.20 pa-risc1.1 with `gcc' 3.1:
  5790.      `CFLAGS="-DHPUX -I/opt/dce/include -O3 -fPIC" CXX=gcc
  5791.      CXXFLAGS="-DHPUX -I/opt/dce /include -felide-constructors
  5792.      -fno-exceptions -fno-rtti -O3 -fPIC" ./configure
  5793.      --prefix=/usr/local/mysql --with-extra-charsets=complex
  5794.      --enable-thread-safe-client --enable-local-infile  --with-pthread
  5795.      --with-named-thread-libs=-ldce --with-lib-ccflags=-fPIC
  5796.      --disable-shared'
  5797.  
  5798. HP-UX 11.00 pa-risc with `aCC' (HP ANSI C++ B3910B A.03.50):
  5799.      `CC=cc CXX=aCC CFLAGS=+DAportable CXXFLAGS=+DAportable ./configure
  5800.      --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data
  5801.      --libexecdir=/usr/local/mysql/bin --with-extra-charsets=complex
  5802.      --enable-thread-safe-client --enable-local-infile --disable-shared
  5803.      --with-embedded-server --with-innodb'
  5804.  
  5805. HP-UX 11.11 pa-risc2.0 64bit with `aCC' (HP ANSI C++ B3910B A.03.33):
  5806.      `CC=cc CXX=aCC CFLAGS=+DD64 CXXFLAGS=+DD64 ./configure
  5807.      --prefix=/usr/local/mysql --with-extra-charsets=complex
  5808.      --enable-thread-safe-client --enable-local-infile --disable-shared'
  5809.  
  5810. HP-UX 11.11 pa-risc2.0 32bit with `aCC' (HP ANSI C++ B3910B A.03.33):
  5811.      `CC=cc CXX=aCC CFLAGS="+DAportable" CXXFLAGS="+DAportable"
  5812.      ./configure --prefix=/usr/local/mysql
  5813.      --localstatedir=/usr/local/mysql/data
  5814.      --libexecdir=/usr/local/mysql/bin --with-extra-charsets=complex
  5815.      --enable-thread-safe-client --enable-local-infile
  5816.      --disable-shared --with-innodb'
  5817.  
  5818. HP-UX 11.22 ia64 64bit with `aCC' (HP aC++/ANSI C B3910B A.05.50):
  5819.      `CC=cc CXX=aCC CFLAGS="+DD64 +DSitanium2" CXXFLAGS="+DD64
  5820.      +DSitanium2" ./configure --prefix=/usr/local/mysql
  5821.      --localstatedir=/usr/local/mysql/data
  5822.      --libexecdir=/usr/local/mysql/bin --with-extra-charsets=complex
  5823.      --enable-thread-safe-client --enable-local-infile
  5824.      --disable-shared --with-embedded-server --with-innodb'
  5825.  
  5826. Apple Mac OS X 10.2 powerpc with `gcc' 3.1:
  5827.      `CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-O3
  5828.      -fno-omit-frame-pointer -felide-constructors -fno-exceptions
  5829.      -fno-rtti" ./configure --prefix=/usr/local/mysql
  5830.      --with-extra-charsets=complex --enable-thread-safe-client
  5831.      --enable-local-infile  --disable-shared'
  5832.  
  5833. FreeBSD 4.7 i386 with `gcc' 2.95.4:
  5834.      `CFLAGS=-DHAVE_BROKEN_REALPATH ./configure
  5835.      --prefix=/usr/local/mysql --with-extra-charsets=complex
  5836.      --enable-thread-safe-client --enable-local-infile
  5837.      --enable-assembler --with-named-z-libs=not-used --disable-shared'
  5838.  
  5839. FreeBSD 4.7 i386 using LinuxThreads with `gcc' 2.95.4:
  5840.      `CFLAGS="-DHAVE_BROKEN_REALPATH -D__USE_UNIX98 -D_REENTRANT
  5841.      -D_THREAD_SAFE -I/usr/local/include/pthread/linuxthreads"
  5842.      CXXFLAGS="-DHAVE_BROKEN_REALPATH -D__USE_UNIX98 -D_REENTRANT
  5843.      -D_THREAD_SAFE -I/usr/local/include/pthread/linuxthreads"
  5844.      ./configure --prefix=/usr/local/mysql
  5845.      --localstatedir=/usr/local/mysql/data
  5846.      --libexecdir=/usr/local/mysql/bin --enable-thread-safe-client
  5847.      --enable-local-infile --enable-assembler
  5848.      --with-named-thread-libs="-DHAVE_GLIBC2_STYLE_GETHOSTBYNAME_R
  5849.      -D_THREAD_SAFE -I /usr/local/include/pthread/linuxthreads
  5850.      -L/usr/local/lib -llthread -llgcc_r" --disable-shared
  5851.      --with-embedded-server --with-innodb'
  5852.  
  5853. QNX Neutrino 6.2.1 i386 with `gcc' 2.95.3qnx-nto 20010315:
  5854.      `CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-O3
  5855.      -fno-omit-frame-pointer -felide-constructors -fno-exceptions
  5856.      -fno-rtti" ./configure --prefix=/usr/local/mysql
  5857.      --with-extra-charsets=complex --enable-thread-safe-client
  5858.      --enable-local-infile  --disable-shared'
  5859.  
  5860. The following binaries are built on third-party systems kindly provided
  5861. to MySQL AB by other users. These are provided only as a courtesy;
  5862. MySQL AB does not have full control over these systems, so we can
  5863. provide only limited support for the binaries built on them.
  5864.  
  5865. SCO Unix 3.2v5.0.6 i386 with `gcc' 2.95.3:
  5866.      `CFLAGS="-O3 -mpentium" LDFLAGS=-static CXX=gcc CXXFLAGS="-O3
  5867.      -mpentium -felide-constructors" ./configure
  5868.      --prefix=/usr/local/mysql --with-extra-charsets=complex
  5869.      --enable-thread-safe-client --enable-local-infile
  5870.      --with-named-z-libs=no --enable-thread-safe-client
  5871.      --disable-shared'
  5872.  
  5873. SCO OpenUnix 8.0.0 i386 with `CC' 3.2:
  5874.      `CC=cc CFLAGS="-O" CXX=CC ./configure --prefix=/usr/local/mysql
  5875.      --with-extra-charsets=complex --enable-thread-safe-client
  5876.      --enable-local-infile --with-named-z-libs=no
  5877.      --enable-thread-safe-client --disable-shared'
  5878.  
  5879. Compaq Tru64 OSF/1 V5.1 732 alpha with `cc/cxx' (Compaq C V6.3-029i / DIGITAL C++ V6.1-027):
  5880.      `CC="cc -pthread" CFLAGS="-O4 -ansi_alias -ansi_args -fast -inline
  5881.      speed -speculate all" CXX="cxx -pthread" CXXFLAGS="-O4 -ansi_alias
  5882.      -fast -inline speed -speculate all -noexceptions -nortti"
  5883.      ./configure --prefix=/usr/local/mysql
  5884.      --with-extra-charsets=complex --enable-thread-safe-client
  5885.      --enable-local-infile --with-prefix=/usr/local/mysql
  5886.      --with-named-thread-libs="-lpthread -lmach -lexc -lc"
  5887.      --disable-shared --with-mysqld-ldflags=-all-static'
  5888.  
  5889. SGI Irix 6.5 IP32 with `gcc' 3.0.1:
  5890.      `CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXXFLAGS="-O3
  5891.      -fno-omit-frame-pointer -felide-constructors -fno-exceptions
  5892.      -fno-rtti" ./configure --prefix=/usr/local/mysql
  5893.      --with-extra-charsets=complex --enable-thread-safe-client
  5894.      --enable-local-infile  --disable-shared'
  5895.  
  5896. FreeBSD/sparc64 5.0 with `gcc' 3.2.1:
  5897.      `CFLAGS=-DHAVE_BROKEN_REALPATH ./configure
  5898.      --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data
  5899.      --libexecdir=/usr/local/mysql/bin --with-extra-charsets=complex
  5900.      --enable-thread-safe-client --enable-local-infile --disable-shared
  5901.      --with-innodb'
  5902.  
  5903. The following compile options have been used for binary packages that
  5904. MySQL AB provided in the past. These binaries no longer are being
  5905. updated, but the compile options are listed here for reference purposes.
  5906.  
  5907. Linux 2.2.xx SPARC with `egcs' 1.1.2:
  5908.      `CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-O3
  5909.      -fno-omit-frame-pointer -felide-constructors -fno-exceptions
  5910.      -fno-rtti" ./configure --prefix=/usr/local/mysql
  5911.      --with-extra-charsets=complex --enable-thread-safe-client
  5912.      --enable-local-infile --enable-assembler --disable-shared'
  5913.  
  5914. Linux 2.2.x with x686 with `gcc' 2.95.2:
  5915.      `CFLAGS="-O3 -mpentiumpro" CXX=gcc CXXFLAGS="-O3 -mpentiumpro
  5916.      -felide-constructors -fno-exceptions -fno-rtti" ./configure
  5917.      --prefix=/usr/local/mysql --enable-assembler
  5918.      --with-mysqld-ldflags=-all-static --disable-shared
  5919.      --with-extra-charsets=complex'
  5920.  
  5921. SunOS 4.1.4 2 sun4c with `gcc' 2.7.2.1:
  5922.      `CC=gcc CXX=gcc CXXFLAGS="-O3 -felide-constructors" ./configure
  5923.      --prefix=/usr/local/mysql --disable-shared
  5924.      --with-extra-charsets=complex --enable-assembler'
  5925.  
  5926. SunOS 5.5.1 (and above) sun4u with `egcs' 1.0.3a or 2.90.27 or
  5927.      `gcc' 2.95.2 and newer: `CC=gcc CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3
  5928.      -felide-constructors -fno-exceptions -fno-rtti" ./configure
  5929.      --prefix=/usr/local/mysql --with-low-memory
  5930.      --with-extra-charsets=complex --enable-assembler'
  5931.  
  5932. SunOS 5.6 i86pc with `gcc' 2.8.1:
  5933.      `CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql
  5934.      --with-low-memory --with-extra-charsets=complex'
  5935.  
  5936. BSDI BSD/OS 3.1 i386 with `gcc' 2.7.2.1:
  5937.      `CC=gcc CXX=gcc CXXFLAGS=-O ./configure --prefix=/usr/local/mysql
  5938.      --with-extra-charsets=complex'
  5939.  
  5940. BSDI BSD/OS 2.1 i386 with `gcc' 2.7.2:
  5941.      `CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql
  5942.      --with-extra-charsets=complex'
  5943.  
  5944. AIX 4.2 with `gcc' 2.7.2.2:
  5945.      `CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql
  5946.      --with-extra-charsets=complex'
  5947.  
  5948. Anyone who has more optimal options for any of the preceding
  5949. configurations listed can always mail them to the MySQL `internals'
  5950. mailing list.  *Note Mailing-list::.
  5951.  
  5952. RPM distributions prior to MySQL 3.22 are user-contributed.  Beginning
  5953. with MySQL 3.22, RPM distributions are generated by MySQL AB.
  5954.  
  5955. If you want to compile a debug version of MySQL, you should add
  5956. `--with-debug' or `--with-debug=full' to the preceding `configure'
  5957. commands and remove any `-fomit-frame-pointer' options.
  5958.  
  5959. How to Get MySQL
  5960. ----------------
  5961.  
  5962. Check the MySQL downloads page (`http://dev.mysql.com/downloads/') for
  5963. information about the current version and for downloading instructions.
  5964. For a complete up-to-date list of MySQL download mirror sites, see
  5965. `http://dev.mysql.com/downloads/mirrors.html'.  There you will also
  5966. find information about becoming a MySQL mirror site and how to report a
  5967. bad or out-of-date mirror.
  5968.  
  5969. Our main mirror is located at `http://mirrors.sunsite.dk/mysql/'.
  5970.  
  5971. Verifying Package Integrity Using MD5 Checksums or `GnuPG'
  5972. ----------------------------------------------------------
  5973.  
  5974. After you have downloaded the MySQL package that suits your needs and
  5975. before you attempt to install it, you should make sure that it is
  5976. intact and has not been tampered with. MySQL AB offers three means of
  5977. integrity checking:
  5978.  
  5979.    * MD5 checksums
  5980.  
  5981.    * Cryptographic signatures using `GnuPG', the GNU Privacy Guard
  5982.  
  5983.    * For RPM packages, the built-in RPM integrity verification mechanism
  5984.  
  5985.  
  5986. The following sections describe how to use these methods.
  5987.  
  5988. If you notice that the MD5 checksum or GPG signatures do not match,
  5989. first try to download the respective package one more time, perhaps
  5990. from another mirror site. If you repeatedly cannot successfully verify
  5991. the integrity of the package, please notify us about such incidents,
  5992. including the full package name and the download site you have been
  5993. using, at <webmaster@mysql.com> or <build@mysql.com>.  Do not report
  5994. downloading problems using the bug-reporting system.
  5995.  
  5996. Verifying the MD5 Checksum
  5997. ..........................
  5998.  
  5999. After you have downloaded a MySQL package, you should make sure that
  6000. its MD5 checksum matches the one provided on the MySQL download pages.
  6001. Each package has an individual checksum that you can verify with the
  6002. following command, where `package_name' is the name of the package you
  6003. downloaded:
  6004.  
  6005.      shell> md5sum package_name
  6006.  
  6007. Example:
  6008.      shell> md5sum mysql-standard-4.0.17-pc-linux-i686.tar.gz
  6009.      60f5fe969d61c8f82e4f7f62657e1f06  mysql-standard-4.0.17-pc-linux-i686.tar.gz
  6010.  
  6011. You should verify that the resulting checksum (the string of hexadecimal
  6012. digits) matches the one displayed on the download page immediately
  6013. below the respective package.
  6014.  
  6015. Note that not all operating systems support the `md5sum' command. On
  6016. some, it is simply called `md5' and others do not ship it at all. On
  6017. Linux, it is part of the `GNU Text Utilities' package, which is
  6018. available for a wide range of platforms. You can download the source
  6019. code from `http://www.gnu.org/software/textutils/' as well. If you have
  6020. `OpenSSL' installed, you can also use the command `openssl md5
  6021. package_name' instead. A DOS/Windows implementation of the `md5'
  6022. command is available from `http://www.fourmilab.ch/md5/'.
  6023.  
  6024. Signature Checking Using `GnuPG'
  6025. ................................
  6026.  
  6027. Another method of verifying the integrity and authenticity of a package
  6028. is to use cryptographic signatures. This is more reliable than using MD5
  6029. checksums, but requires more work.
  6030.  
  6031. Beginning with MySQL 4.0.10 (February 2003), MySQL AB started signing
  6032. downloadable packages with `GnuPG' (`GNU Privacy Guard').  `GnuPG' is
  6033. an Open Source alternative to the very well-known `Pretty Good Privacy'
  6034. (`PGP') by Phil Zimmermann.  See `http://www.gnupg.org/' for more
  6035. information about `GnuPG' and how to obtain and install it on your
  6036. system. Most Linux distributions already ship with `GnuPG' installed by
  6037. default.  For more information about `OpenPGP', see
  6038. `http://www.openpgp.org/'.
  6039.  
  6040. To verify the signature for a specific package, you first need to
  6041. obtain a copy of MySQL AB's public GPG build key. You can download the
  6042. key from `http://www.keyserver.net/'.  The key that you want to obtain
  6043. is named `build@mysql.com'.  Alternatively, you can cut and paste the
  6044. key directly from the following text:
  6045.  
  6046.      Key ID:
  6047.      pub  1024D/5072E1F5 2003-02-03
  6048.           MySQL Package signing key (www.mysql.com) <build@mysql.com>
  6049.      Fingerprint: A4A9 4068 76FC BD3C 4567  70C8 8C71 8D3B 5072 E1F5
  6050.      
  6051.      Public Key (ASCII-armored):
  6052.      
  6053.      -----BEGIN PGP PUBLIC KEY BLOCK-----
  6054.      Version: GnuPG v1.0.6 (GNU/Linux)
  6055.      Comment: For info see http://www.gnupg.org
  6056.      
  6057.      mQGiBD4+owwRBAC14GIfUfCyEDSIePvEW3SAFUdJBtoQHH/nJKZyQT7h9bPlUWC3
  6058.      RODjQReyCITRrdwyrKUGku2FmeVGwn2u2WmDMNABLnpprWPkBdCk96+OmSLN9brZ
  6059.      fw2vOUgCmYv2hW0hyDHuvYlQA/BThQoADgj8AW6/0Lo7V1W9/8VuHP0gQwCgvzV3
  6060.      BqOxRznNCRCRxAuAuVztHRcEAJooQK1+iSiunZMYD1WufeXfshc57S/+yeJkegNW
  6061.      hxwR9pRWVArNYJdDRT+rf2RUe3vpquKNQU/hnEIUHJRQqYHo8gTxvxXNQc7fJYLV
  6062.      K2HtkrPbP72vwsEKMYhhr0eKCbtLGfls9krjJ6sBgACyP/Vb7hiPwxh6rDZ7ITnE
  6063.      kYpXBACmWpP8NJTkamEnPCia2ZoOHODANwpUkP43I7jsDmgtobZX9qnrAXw+uNDI
  6064.      QJEXM6FSbi0LLtZciNlYsafwAPEOMDKpMqAK6IyisNtPvaLd8lH0bPAnWqcyefep
  6065.      rv0sxxqUEMcM3o7wwgfN83POkDasDbs3pjwPhxvhz6//62zQJ7Q7TXlTUUwgUGFj
  6066.      a2FnZSBzaWduaW5nIGtleSAod3d3Lm15c3FsLmNvbSkgPGJ1aWxkQG15c3FsLmNv
  6067.      bT6IXQQTEQIAHQUCPj6jDAUJCWYBgAULBwoDBAMVAwIDFgIBAheAAAoJEIxxjTtQ
  6068.      cuH1cY4AnilUwTXn8MatQOiG0a/bPxrvK/gCAJ4oinSNZRYTnblChwFaazt7PF3q
  6069.      zIhMBBMRAgAMBQI+PqPRBYMJZgC7AAoJEElQ4SqycpHyJOEAn1mxHijft00bKXvu
  6070.      cSo/pECUmppiAJ41M9MRVj5VcdH/KN/KjRtW6tHFPYhMBBMRAgAMBQI+QoIDBYMJ
  6071.      YiKJAAoJELb1zU3GuiQ/lpEAoIhpp6BozKI8p6eaabzF5MlJH58pAKCu/ROofK8J
  6072.      Eg2aLos+5zEYrB/LsrkCDQQ+PqMdEAgA7+GJfxbMdY4wslPnjH9rF4N2qfWsEN/l
  6073.      xaZoJYc3a6M02WCnHl6ahT2/tBK2w1QI4YFteR47gCvtgb6O1JHffOo2HfLmRDRi
  6074.      Rjd1DTCHqeyX7CHhcghj/dNRlW2Z0l5QFEcmV9U0Vhp3aFfWC4Ujfs3LU+hkAWzE
  6075.      7zaD5cH9J7yv/6xuZVw411x0h4UqsTcWMu0iM1BzELqX1DY7LwoPEb/O9Rkbf4fm
  6076.      Le11EzIaCa4PqARXQZc4dhSinMt6K3X4BrRsKTfozBu74F47D8Ilbf5vSYHbuE5p
  6077.      /1oIDznkg/p8kW+3FxuWrycciqFTcNz215yyX39LXFnlLzKUb/F5GwADBQf+Lwqq
  6078.      a8CGrRfsOAJxim63CHfty5mUc5rUSnTslGYEIOCR1BeQauyPZbPDsDD9MZ1ZaSaf
  6079.      anFvwFG6Llx9xkU7tzq+vKLoWkm4u5xf3vn55VjnSd1aQ9eQnUcXiL4cnBGoTbOW
  6080.      I39EcyzgslzBdC++MPjcQTcA7p6JUVsP6oAB3FQWg54tuUo0Ec8bsM8b3Ev42Lmu
  6081.      QT5NdKHGwHsXTPtl0klk4bQk4OajHsiy1BMahpT27jWjJlMiJc+IWJ0mghkKHt92
  6082.      6s/ymfdf5HkdQ1cyvsz5tryVI3Fx78XeSYfQvuuwqp2H139pXGEkg0n6KdUOetdZ
  6083.      Whe70YGNPw1yjWJT1IhMBBgRAgAMBQI+PqMdBQkJZgGAAAoJEIxxjTtQcuH17p4A
  6084.      n3r1QpVC9yhnW2cSAjq+kr72GX0eAJ4295kl6NxYEuFApmr1+0uUq/SlsQ==
  6085.      =YJkx
  6086.      -----END PGP PUBLIC KEY BLOCK-----
  6087.  
  6088. You can import the build key into your personal public GPG keyring by
  6089. using `gpg --import'. For example, if you save the key in a file named
  6090. `mysql_pubkey.asc', the import command looks like this:
  6091.  
  6092.      shell> gpg --import mysql_pubkey.asc
  6093.  
  6094. See the GPG documentation for more information on how to work with
  6095. public keys.
  6096.  
  6097. After you have downloaded and imported the public build key, download
  6098. your desired MySQL package and the corresponding signature, which also
  6099. is available from the download page.  The signature file has the same
  6100. name as the distribution file with an `.asc' extension. For example:
  6101.  
  6102. Distribution file      `mysql-standard-4.0.17-pc-linux-i686.tar.gz'
  6103. Signature file         `mysql-standard-4.0.17-pc-linux-i686.tar.gz.asc'
  6104.  
  6105. Make sure that both files are stored in the same directory and then run
  6106. the following command to verify the signature for the distribution file:
  6107.  
  6108.      shell> gpg --verify package_name.asc
  6109.  
  6110. Example:
  6111.  
  6112.      shell> gpg --verify mysql-standard-4.0.17-pc-linux-i686.tar.gz.asc
  6113.      gpg: Warning: using insecure memory!
  6114.      gpg: Signature made Mon 03 Feb 2003 08:50:39 PM MET
  6115.      using DSA key ID 5072E1F5
  6116.      gpg: Good signature from
  6117.           "MySQL Package signing key (www.mysql.com) <build@mysql.com>"
  6118.  
  6119. The `Good signature' message indicates that everything is all right.
  6120. You can ignore the `insecure memory' warning.
  6121.  
  6122. Signature Checking Using `RPM'
  6123. ..............................
  6124.  
  6125. For RPM packages, there is no separate signature. RPM packages have a
  6126. built-in GPG signature and MD5 checksum. You can verify a package by
  6127. running the following command:
  6128.  
  6129.      shell> rpm --checksig package_name.rpm
  6130.  
  6131. Example:
  6132.  
  6133.      shell> rpm --checksig MySQL-server-4.0.10-0.i386.rpm
  6134.      MySQL-server-4.0.10-0.i386.rpm: md5 gpg OK
  6135.  
  6136. *Note*: If you are using RPM 4.1 and it complains about `(GPG) NOT OK
  6137. (MISSING KEYS: GPG#5072e1f5)', even though you have imported the MySQL
  6138. public build key into your own GPG keyring, you need to import the key
  6139. into the RPM keyring first. RPM 4.1 no longer uses your personal GPG
  6140. keyring (or GPG itself). Rather, it maintains its own keyring because
  6141. it is a system-wide application and a user's GPG public keyring is a
  6142. user-specific file. To import the MySQL public key into the RPM
  6143. keyring, first obtain the key as described in the previous section.
  6144. Then use `rpm --import' to import the key.  For example, if you have
  6145. the public key stored in a file named `mysql_pubkey.asc', import it
  6146. using this command:
  6147.  
  6148.      shell> rpm --import mysql_pubkey.asc
  6149.  
  6150. Installation Layouts
  6151. --------------------
  6152.  
  6153. This section describes the default layout of the directories created by
  6154. installing binary or source distributions provided by MySQL AB. If you
  6155. install a distribution provided by another vendor, some other layout
  6156. might be used.
  6157.  
  6158. On Windows, the default installation directory is `C:\mysql', which has
  6159. the following subdirectories:
  6160.  
  6161. *Directory*               *Contents of Directory*
  6162. `bin'                     Client programs and the
  6163.                           `mysqld' server
  6164. `data'                    Log files, databases
  6165. `Docs'                    Documentation
  6166. `examples'                Example programs and scripts
  6167. `include'                 Include (header) files
  6168. `lib'                     Libraries
  6169. `scripts'                 Utility scripts
  6170. `share'                   Error message files
  6171.  
  6172. Installations created from Linux RPM distributions result in files under
  6173. the following system directories:
  6174.  
  6175. *Directory*               *Contents of Directory*
  6176. `/usr/bin'                Client programs and scripts
  6177. `/usr/sbin'               The `mysqld' server
  6178. `/var/lib/mysql'          Log files, databases
  6179. `/usr/share/doc/packages' Documentation
  6180. `/usr/include/mysql'      Include (header) files
  6181. `/usr/lib/mysql'          Libraries
  6182. `/usr/share/mysql'        Error message and character set
  6183.                           files
  6184. `/usr/share/sql-bench'    Benchmarks
  6185.  
  6186. On Unix, a `tar' file binary distribution is installed by unpacking it
  6187. at the installation location you choose (typically `/usr/local/mysql')
  6188. and creates the following directories in that location:
  6189.  
  6190. *Directory*               *Contents of Directory*
  6191. `bin'                     Client programs and the
  6192.                           `mysqld' server
  6193. `data'                    Log files, databases
  6194. `docs'                    Documentation, ChangeLog
  6195. `include'                 Include (header) files
  6196. `lib'                     Libraries
  6197. `scripts'                 `mysql_install_db'
  6198. `share/mysql'             Error message files
  6199. `sql-bench'               Benchmarks
  6200.  
  6201. A source distribution is installed after you configure and compile it.
  6202. By default, the installation step installs files under `/usr/local', in
  6203. the following subdirectories:
  6204.  
  6205. *Directory*               *Contents of Directory*
  6206. `bin'                     Client programs and scripts
  6207. `include/mysql'           Include (header) files
  6208. `info'                    Documentation in Info format
  6209. `lib/mysql'               Libraries
  6210. `libexec'                 The `mysqld' server
  6211. `share/mysql'             Error message files
  6212. `sql-bench'               Benchmarks and `crash-me' test
  6213. `var'                     Databases and log files
  6214.  
  6215. Within an installation directory, the layout of a source installation
  6216. differs from that of a binary installation in the following ways:
  6217.  
  6218.    * The `mysqld' server is installed in the `libexec' directory rather
  6219.      than in the `bin' directory.
  6220.  
  6221.    * The data directory is `var' rather than `data'.
  6222.  
  6223.    * `mysql_install_db' is installed in the `bin' directory rather than
  6224.      in the `scripts' directory.
  6225.  
  6226.    * The header file and library directories are `include/mysql' and
  6227.      `lib/mysql' rather than `include' and `lib'.
  6228.  
  6229. You can create your own binary installation from a compiled source
  6230. distribution by executing the `scripts/make_binary_distribution' script
  6231. from the top directory of the source distribution.
  6232.  
  6233. Standard MySQL Installation Using a Binary Distribution
  6234. =======================================================
  6235.  
  6236. This section covers the installation of MySQL on platforms where we
  6237. offer packages using the native packaging format of the respective
  6238. platform. (This is also known as performing a "binary install.")
  6239. However, binary distributions of MySQL are available for many other
  6240. platforms as well. See *Note Installing binary:: for generic
  6241. installation instructions for these packages that apply to all
  6242. platforms.
  6243.  
  6244. See *Note General Installation Issues:: for more information on what
  6245. other binary distributions are available and how to obtain them.
  6246.  
  6247. Installing MySQL on Windows
  6248. ---------------------------
  6249.  
  6250. The installation process for MySQL on Windows has the following steps:
  6251.  
  6252.   1. Obtain and install the distribution.
  6253.  
  6254.   2. Set up an option file if necessary.
  6255.  
  6256.   3. Select the server you want to use.
  6257.  
  6258.   4. Start the server.
  6259.  
  6260.   5. Assign passwords to the initial MySQL accounts.
  6261.  
  6262.  
  6263. MySQL for Windows is available in two distribution formats:
  6264.  
  6265.    * The binary distribution contains a setup program that installs
  6266.      everything you need so that you can start the server immediately.
  6267.  
  6268.    * The source distribution contains all the code and support files
  6269.      for building the executables using the VC++ 6.0 compiler.
  6270.  
  6271.  
  6272. Generally speaking, you should use the binary distribution. It's
  6273. simpler, and you need no additional tools to get MySQL up and running.
  6274.  
  6275. This section describes how to install MySQL on Windows using a binary
  6276. distribution.  To install using a source distribution, see *Note
  6277. Windows source build::.
  6278.  
  6279. Windows System Requirements
  6280. ...........................
  6281.  
  6282. To run MySQL on Windows, you need the following:
  6283.  
  6284.    * A 32-bit Windows operating system such as 9x, Me, NT, 2000, or XP.
  6285.      The NT family (Windows NT, 2000, and XP) permits you to run the
  6286.      MySQL server as a service. *Note NT start::.
  6287.  
  6288.    * TCP/IP protocol support.
  6289.  
  6290.    * A copy of the MySQL binary distribution for Windows, which can be
  6291.      downloaded from `http://dev.mysql.com/downloads/'.  *Note Getting
  6292.      MySQL::.
  6293.  
  6294.      Note: If you download the distribution via FTP, we recommend the
  6295.      use of an adequate FTP client with a resume feature to avoid
  6296.      corruption of files during the download process.
  6297.  
  6298.    * `WinZip' or other Windows tool that can read `.zip' files, to
  6299.      unpack the distribution file.
  6300.  
  6301.    * Enough space on the hard drive to unpack, install, and create the
  6302.      databases in accordance with your requirements.
  6303.  
  6304.    * If you plan to connect to the MySQL server via ODBC, you also need
  6305.      the `MyODBC' driver. *Note ODBC::.
  6306.  
  6307.    * If you need tables with a size larger than 4GB, install MySQL on
  6308.      an NTFS or newer filesystem. Don't forget to use `MAX_ROWS' and
  6309.      `AVG_ROW_LENGTH' when you create tables.  *Note `CREATE TABLE':
  6310.      CREATE TABLE.
  6311.  
  6312.  
  6313. Installing a Windows Binary Distribution
  6314. ........................................
  6315.  
  6316. To install MySQL on Windows using a binary distribution, follow this
  6317. procedure:
  6318.  
  6319.   1. If you are working on a Windows NT, 2000, or XP machine, make sure
  6320.      that you have logged in as a user with administrator privileges.
  6321.  
  6322.   2. If you are doing an upgrade of an earlier MySQL installation, it
  6323.      is necessary to stop the current server.  On Windows NT, 2000, or
  6324.      XP machines, if you are running the server as a Windows service,
  6325.      stop it as follows from the command prompt:
  6326.  
  6327.           C:\> NET STOP MySQL
  6328.  
  6329.      If you plan to use a different server after the upgrade (for
  6330.      example, if you want to run `mysqld-max' rather than `mysqld'),
  6331.      remove the existing service:
  6332.  
  6333.           C:\> C:\mysql\bin\mysqld --remove
  6334.  
  6335.      You can reinstall the service to use the proper server after
  6336.      upgrading.
  6337.  
  6338.      If you are not running the MySQL server as a service, stop it like
  6339.      this:
  6340.  
  6341.           C:\> C:\mysql\bin\mysqladmin -u root shutdown
  6342.  
  6343.   3. Exit the `WinMySQLAdmin' program if it is running.
  6344.  
  6345.   4. Unzip the distribution file to a temporary directory.
  6346.  
  6347.   5. Run the `setup.exe' program to begin the installation process.  If
  6348.      you want to install MySQL into a location other than the default
  6349.      directory (`C:\mysql'), use the `Browse' button to specify your
  6350.      preferred directory. If you do not install MySQL into the default
  6351.      location, you will need to specify the location whenever you start
  6352.      the server. The easiest way to do this is to use an option file,
  6353.      as described in *Note Windows prepare environment::.
  6354.  
  6355.   6. Finish the install process.
  6356.  
  6357.  
  6358. *Important note:* Early alpha Windows distributions for MySQL 4.1 do
  6359. not contain an installer program.  A 4.1 distribution is a Zip file
  6360. that you just unzip in the location where you want to install MySQL.
  6361. For example, to install `mysql-4.1.1-alpha-win.zip' as `C:\mysql', unzip
  6362. the distribution file on the `C:' drive, then rename the resulting
  6363. `mysql-4.1.1-alpha' directory to `mysql'.
  6364.  
  6365. If you are upgrading to MySQL 4.1 from an earlier version, you will
  6366. want to preserve your existing `data' directory that contains the grant
  6367. tables in the `mysql' database and your own databases.  Before
  6368. installing 4.1, stop the server if it is running, and save your `data'
  6369. directory to another location. Then either rename the existing
  6370. `C:\mysql' directory or remove it.  Install 4.1 as described in the
  6371. preceding paragraph, and then replace its `data' directory with your
  6372. old `data' directory.  This will avoid the loss of your current
  6373. databases.  Start the new server and update the grant tables.  *Note
  6374. Upgrading-grant-tables::.
  6375.  
  6376. Please see *Note Windows troubleshooting:: if you encounter
  6377. difficulties during installation.
  6378.  
  6379. Preparing the Windows MySQL Environment
  6380. .......................................
  6381.  
  6382. If you need to specify startup options when you run the server, you can
  6383. indicate them on the command line or place them in an option file. For
  6384. options that will be used every time the server starts, you will find
  6385. it most convenient to use an option file to specify your MySQL
  6386. configuration. This is true particularly under the following
  6387. circumstances:
  6388.  
  6389.    * The installation or data directory locations are different from
  6390.      the default locations (`C:\mysql' and `C:\mysql\data').
  6391.  
  6392.    * You need to tune the server settings.  For example, to use the
  6393.      `InnoDB' transactional tables in MySQL 3.23, you must manually add
  6394.      some extra lines to the option file, as described in *Note
  6395.      `InnoDB' configuration: InnoDB configuration.  (As of MySQL 4.0,
  6396.      `InnoDB' creates its data files and log files in the data
  6397.      directory by default. This means you need not configure `InnoDB'
  6398.      explicitly.  You may still do so if you wish, and an option file
  6399.      will be useful in this case, too.)
  6400.  
  6401.  
  6402. On Windows, the MySQL installer places the data directory directly under
  6403. the directory where you install MySQL.  If you would like to use a data
  6404. directory in a different location, you should copy the entire contents
  6405. of the `data' directory to the new location. For example, by default,
  6406. the installer places MySQL in `C:\mysql' and the data directory in
  6407. `C:\mysql\data'. If you want to use a data directory of `E:\mydata',
  6408. you must do two things:
  6409.  
  6410.    * Move the data directory from `C:\mysql\data' to `E:\mydata'.
  6411.  
  6412.    * Use a `--datadir' option to specify the new data directory location
  6413.      each time you start the server.
  6414.  
  6415.  
  6416. When the MySQL server starts on Windows, it looks for options in two
  6417. files:  the `my.ini' file in the Windows directory, and the `C:\my.cnf'
  6418. file.  The Windows directory typically is named something like
  6419. `C:\WINDOWS' or `C:\WinNT'.  You can determine its exact location from
  6420. the value of the `WINDIR' environment variable using the following
  6421. command:
  6422.  
  6423.      C:\> echo %WINDIR%
  6424.  
  6425. MySQL looks for options first in the `my.ini' file, then in the
  6426. `my.cnf' file.  However, to avoid confusion, it's best if you use only
  6427. one file.  If your PC uses a boot loader where the `C:' drive isn't the
  6428. boot drive, your only option is to use the `my.ini' file.  Whichever
  6429. option file you use, it must be a plain text file.
  6430.  
  6431. An option file can be created and modified with any text editor, such
  6432. as the `Notepad' program.  For example, if MySQL is installed at
  6433. `E:\mysql' and the data directory is located at `E:\mydata\data', you
  6434. can create the option file and set up a `[mysqld]' section to specify
  6435. values for the `basedir' and `datadir' parameters:
  6436.  
  6437.      [mysqld]
  6438.      # set basedir to your installation path
  6439.      basedir=E:/mysql
  6440.      # set datadir to the location of your data directory
  6441.      datadir=E:/mydata/data
  6442.  
  6443. Note that Windows pathnames are specified in option files using forward
  6444. slashes rather than backslashes.  If you do use backslashes, you must
  6445. double them.
  6446.  
  6447. Another way to manage an option file is to use the `WinMySQLAdmin'
  6448. tool. You can find `WinMySQLAdmin' in the `bin' directory of your MySQL
  6449. installation, as well as a help file containing instructions for using
  6450. it. `WinMySQLAdmin' has the capability of editing your option file, but
  6451. note these points:
  6452.  
  6453.    * `WinMySQLAdmin' uses only the `my.ini' file.
  6454.  
  6455.    * If `WinMySQLAdmin' finds a `C:\my.cnf' file, it will in fact rename
  6456.      it to `C:\my_cnf.bak' to disable it.
  6457.  
  6458.  
  6459. Now you are ready to start the server.
  6460.  
  6461. Selecting a Windows Server
  6462. ..........................
  6463.  
  6464. Starting with MySQL 3.23.38, the Windows distribution includes both the
  6465. normal and the MySQL-Max server binaries.
  6466.  
  6467. Up through the early releases of MySQL 4.1, the servers included in
  6468. Windows distributions are named like this:
  6469.  
  6470. *Binary*       *Description*
  6471. `mysqld'       Compiled with full debugging and automatic memory
  6472.                allocation checking, symbolic links, and `InnoDB' and
  6473.                `BDB' tables.
  6474. `mysqld-opt'   Optimized binary.  From version 4.0 on, `InnoDB' is
  6475.                enabled.  Before 4.0, this server includes no
  6476.                transactional table support.
  6477. `mysqld-nt'    Optimized binary for Windows NT, 2000, and XP with
  6478.                support for named pipes.
  6479. `mysqld-max'   Optimized binary with support for symbolic links, and
  6480.                `InnoDB' and `BDB' tables.
  6481. `mysqld-max-nt'Like `mysqld-max', but compiled with support for named
  6482.                pipes.
  6483.  
  6484. We have found that the server with the most generic name (`mysqld') is
  6485. the one that many users are likely to choose by default. However, that
  6486. is also the server that results in the highest memory and CPU use due
  6487. to the inclusion of full debugging support.  The server named
  6488. `mysqld-opt' is a better general-use server choice to make instead if
  6489. you don't need debugging suport and don't want the maximal feature set
  6490. offered by the `-max' servers or named pipe support offered by the
  6491. `-nt' servers.
  6492.  
  6493. To make it less likely that the debugging server would be chosen
  6494. inadvertantly, some name changes were made from MySQL 4.1.2 to 4.1.4:
  6495. `mysqld' has been renamed to `mysqld-debug' and `mysqld-opt' has been
  6496. renamed to `mysqld'.  Thus, the server that includes debugging support
  6497. indicates that in its name, and the server named `mysqld' is an
  6498. efficient default choice. The other servers still have their same
  6499. names. The resulting servers are named like this:
  6500.  
  6501. *Binary*       *Description*
  6502. `mysqld-debug' Compiled with full debugging and automatic memory
  6503.                allocation checking, symbolic links, and `InnoDB' and
  6504.                `BDB' tables.
  6505. `mysqld'       Optimized binary with `InnoDB' support.
  6506. `mysqld-nt'    Optimized binary for Windows NT, 2000, and XP with
  6507.                support for named pipes.
  6508. `mysqld-max'   Optimized binary with support for symbolic links, and
  6509.                `InnoDB' and `BDB' tables.
  6510. `mysqld-max-nt'Like `mysqld-max', but compiled with support for named
  6511.                pipes.
  6512.  
  6513. The name changes were not both instituted at the same time. If you have
  6514. MySQL 4.1.2 or 4.1.3, it might be that you have a server named
  6515. `mysqld-debug' but not one named `mysqld'. In this case, you should
  6516. have have a server `mysqld-opt', which you should choose as your
  6517. default server unless you need maximal features, named pipes, or
  6518. debugging support.
  6519.  
  6520. All of the preceding binaries are optimized for modern Intel processors,
  6521. but should work on any Intel i386-class or higher processor.
  6522.  
  6523. MySQL supports TCP/IP on all Windows platforms. The `mysqld-nt' and
  6524. `mysql-max-nt' servers support named pipes on NT, 2000, and XP.
  6525. However, the default is to use TCP/IP regardless of the platform.
  6526. (Named pipes are slower than TCP/IP in many Windows configurations.)
  6527. Named pipe use is subject to these conditions:
  6528.  
  6529.    * Starting from MySQL 3.23.50, named pipes are enabled only if you
  6530.      start the server with the `--enable-named-pipe' option.  It is now
  6531.      necessary to use this option explicitly because some users have
  6532.      experienced problems shutting down the MySQL server when named
  6533.      pipes were used.
  6534.  
  6535.    * Named pipe connections are allowed only by the `mysqld-nt' or
  6536.      `mysqld-max-nt' servers, and only if the server is run on a
  6537.      version of Windows that supports named pipes (NT, 2000, XP).
  6538.  
  6539.    * These servers can be run on Windows 98 or Me, but only if TCP/IP
  6540.      is installed; named pipe connections cannot be used.
  6541.  
  6542.    * On Windows 95, these servers cannot be used.
  6543.  
  6544.  
  6545. *Note*: Most of the examples in the following sections use `mysqld' as
  6546. the server name. If you choose to use a different server, such as
  6547. `mysqld-opt', make the appropriate substitutions in the commands that
  6548. are shown in the examples. One good reason to choose a different server
  6549. is that because `mysqld' contains full debugging support, it uses more
  6550. memory and runs slower than the other Windows servers.
  6551.  
  6552. Starting the Server for the First Time
  6553. ......................................
  6554.  
  6555. On Windows 95, 98, or Me, MySQL clients always connect to the server
  6556. using TCP/IP.  (This will allow any machine on your network to connect
  6557. to your MySQL server.)  Because of this, you must make sure that TCP/IP
  6558. support is installed on your machine before starting MySQL.  You can
  6559. find TCP/IP on your Windows CD-ROM.
  6560.  
  6561. Note that if you are using an old Windows 95 release (for example,
  6562. OSR2), it's likely that you have an old Winsock package; MySQL requires
  6563. Winsock 2! You can get the newest Winsock from
  6564. `http://www.microsoft.com/'.  Windows 98 has the new Winsock 2 library,
  6565. so it is unnecessary to update the library.
  6566.  
  6567. On NT-based systems such as Windows NT, 2000, or XP, clients have two
  6568. options. They can use TCP/IP, or they can use a named pipe if the server
  6569. supports named pipe connections.
  6570.  
  6571. In MySQL 4.1 and up, Windows servers also support shared-memory
  6572. connections if started with the `--shared-memory' option.  Clients can
  6573. connect this way by using the `--protocol=memory' option.
  6574.  
  6575. For information about which server binary to run, see *Note Windows
  6576. select server::.
  6577.  
  6578. This section gives a general overview of starting the MySQL server.
  6579. The following sections provide more specific information for particular
  6580. versions of Windows.
  6581.  
  6582. The examples in these sections assume that MySQL is installed under the
  6583. default location of `C:\mysql'. Adjust the pathnames shown in the
  6584. examples if you have MySQL installed in a different location.
  6585.  
  6586. Testing is best done from a command prompt in a console window (a "DOS
  6587. window"). This way you can have the server display status messages in
  6588. the window where they are easy to see.  If something is wrong with your
  6589. configuration, these messages will make it easier for you to identify
  6590. and fix any problems.
  6591.  
  6592. To start the server, enter this command:
  6593.  
  6594.      C:\> C:\mysql\bin\mysqld --console
  6595.  
  6596. For servers that include `InnoDB' support, you should see the following
  6597. messages as the server starts:
  6598.  
  6599.      InnoDB: The first specified datafile c:\ibdata\ibdata1 did not exist:
  6600.      InnoDB: a new database to be created!
  6601.      InnoDB: Setting file c:\ibdata\ibdata1 size to 209715200
  6602.      InnoDB: Database physically writes the file full: wait...
  6603.      InnoDB: Log file c:\iblogs\ib_logfile0 did not exist: new to be created
  6604.      InnoDB: Setting log file c:\iblogs\ib_logfile0 size to 31457280
  6605.      InnoDB: Log file c:\iblogs\ib_logfile1 did not exist: new to be created
  6606.      InnoDB: Setting log file c:\iblogs\ib_logfile1 size to 31457280
  6607.      InnoDB: Log file c:\iblogs\ib_logfile2 did not exist: new to be created
  6608.      InnoDB: Setting log file c:\iblogs\ib_logfile2 size to 31457280
  6609.      InnoDB: Doublewrite buffer not found: creating new
  6610.      InnoDB: Doublewrite buffer created
  6611.      InnoDB: creating foreign key constraint system tables
  6612.      InnoDB: foreign key constraint system tables created
  6613.      011024 10:58:25  InnoDB: Started
  6614.  
  6615. When the server finishes its startup sequence, you should see something
  6616. like this, which indicates that the server is ready to service client
  6617. connections:
  6618.  
  6619.      mysqld: ready for connections
  6620.      Version: '4.0.14-log'  socket: ''  port: 3306
  6621.  
  6622. The server will continue to write to the console any further diagnostic
  6623. output it produces.  You can open a new console window in which to run
  6624. client programs.
  6625.  
  6626. If you omit the `--console' option, the server writes diagnostic output
  6627. to the error log in the data directory (`C:\mysql\data' by default).
  6628. The error log is the file with the `.err' extension.
  6629.  
  6630. *Note*: The accounts that are listed in the MySQL grant tables
  6631. initially have no passwords.  After starting the server, you should set
  6632. up passwords for them using the instructions in *Note
  6633. Post-installation::.
  6634.  
  6635. Starting MySQL from the Windows Command Line
  6636. ............................................
  6637.  
  6638. The MySQL server can be started manually from the command line.  This
  6639. can be done on any version of Windows.
  6640.  
  6641. To start the `mysqld' server from the command line, you should start a
  6642. console window (a "DOS window") and enter this command:
  6643.  
  6644.      C:\> C:\mysql\bin\mysqld
  6645.  
  6646. On non-NT versions of Windows, this will start `mysqld' in the
  6647. background. That is, after the server starts, you should see another
  6648. command prompt. If you start the server this way on Windows NT, 2000,
  6649. or XP, the server will run in the foreground and no command prompt will
  6650. appear until the server exits.  Because of this, you should open
  6651. another console window to run client programs while the server is
  6652. running.
  6653.  
  6654. You can stop the MySQL server by executing this command:
  6655.  
  6656.      C:\> C:\mysql\bin\mysqladmin -u root shutdown
  6657.  
  6658. This invokes the MySQL administrative utility `mysqladmin' to connect
  6659. to the server and tell it to shut down. The command connects as `root',
  6660. which is the default administrative account in the MySQL grant system.
  6661. Note that users in the MySQL grant system are wholly independent from
  6662. any login users under Windows.
  6663.  
  6664. If `mysqld' doesn't start, check the error log to see whether the
  6665. server wrote any messages there to indicate the cause of the problem.
  6666. The error log is located in the `C:\mysql\data' directory. It is the
  6667. file with a suffix of `.err'. You can also try to start the server as
  6668. `mysqld --console'; in this case, you may get some useful information
  6669. on the screen that may help solve the problem.
  6670.  
  6671. The last option is to start `mysqld' with `--standalone --debug'.  In
  6672. this case, `mysqld' will write a log file `C:\mysqld.trace' that should
  6673. contain the reason why `mysqld' doesn't start. *Note Making trace
  6674. files::.
  6675.  
  6676. Use `mysqld --help' to display all the options that `mysqld'
  6677. understands!
  6678.  
  6679. Starting MySQL as a Windows Service
  6680. ...................................
  6681.  
  6682. On the NT family (Windows NT, 2000, or XP), the recommended way to run
  6683. MySQL is to install it as a Windows service. Then Windows starts and
  6684. stops the MySQL server automatically when Windows starts and stops. A
  6685. server installed as a service can also be controlled from the command
  6686. line using `NET' commands, or with the graphical `Services' utility.
  6687.  
  6688. The `Services' utility (the Windows `Service Control Manager') can be
  6689. found in the Windows `Control Panel' (under `Administrative Tools' on
  6690. Windows 2000 or XP). It is advisable to close the `Services' utility
  6691. while performing server installation or removal operations from this
  6692. command line.  This prevents some odd errors.
  6693.  
  6694. To get MySQL to work with TCP/IP on Windows NT 4, you must install
  6695. service pack 3 (or newer).
  6696.  
  6697. Before installing MySQL as a Windows service, you should first stop the
  6698. current server if it is running by using the following command:
  6699.  
  6700.      C:\> C:\mysql\bin\mysqladmin -u root shutdown
  6701.  
  6702. This invokes the MySQL administrative utility `mysqladmin' to connect
  6703. to the server and tell it to shut down. The command connects as `root',
  6704. which is the default administrative account in the MySQL grant system.
  6705. Note that users in the MySQL grant system are wholly independent from
  6706. any login users under Windows.
  6707.  
  6708. Now install the server as a service:
  6709.  
  6710.      C:\> mysqld --install
  6711.  
  6712. If you have problems installing `mysqld' as a service using just the
  6713. server name, try installing it using its full pathname:
  6714.  
  6715.      C:\> C:\mysql\bin\mysqld --install
  6716.  
  6717. As of MySQL 4.0.2, you can specify a specific service name after the
  6718. `--install' option.  As of MySQL 4.0.3, you can in addition specify a
  6719. `--defaults-file' option after the service name to indicate where the
  6720. server should obtain options when it starts. The rules that determine
  6721. the service name and option files the server uses are as follows:
  6722.  
  6723.    * If you specify no service name, the server uses the default
  6724.      service name of `MySQL' and the server reads options from the
  6725.      `[mysqld]' group in the standard option files.
  6726.  
  6727.    * If you specify a service name after the `--install' option, the
  6728.      server ignores the `[mysqld]' option group and instead reads
  6729.      options from the group that has the same name as the service. The
  6730.      server reads options from the standard option files.
  6731.  
  6732.    * If you specify a `--defaults-file' option after the service name,
  6733.      the server ignores the standard option files and reads options
  6734.      only from the `[mysqld]' group of the named file.
  6735.  
  6736.  
  6737. *Note*: Prior to MySQL 4.0.17, a server installed as a Windows service
  6738. has problems starting if its pathname or the service name contains
  6739. spaces. For this reason, avoid installing MySQL in a directory such as
  6740. `C:\Program Files' or using a service name containing spaces.
  6741.  
  6742. In the usual case that you install the server with `--install' but no
  6743. service name, the server is installed with a service name of `MySQL'.
  6744.  
  6745. As a more complex example, consider the following command:
  6746.  
  6747.      C:\> C:\mysql\bin\mysqld --install mysql --defaults-file=C:\my-opts.cnf
  6748.  
  6749. Here, a service name is given after the `--install' option. If no
  6750. `--defaults-file' option had been given, this command would have the
  6751. effect of causing the server to read the `[mysql]' group from the
  6752. standard option files. (This would be a bad idea, because that option
  6753. group is for use by the `mysql' client program.) However, because the
  6754. `--defaults-file' option is present, the server reads options only from
  6755. the named file, and only from the `[mysqld]' option group.
  6756.  
  6757. You can also specify options as "`Start parameters'" in the Windows
  6758. `Services' utility before you start the MySQL service.
  6759.  
  6760. Once a MySQL server is installed as a service, Windows will start the
  6761. service automatically whenever Windows starts.  The service also can be
  6762. started immediately from the `Services' utility, or by using the
  6763. command `NET START MySQL'.  The `NET' command is not case sensitive.
  6764.  
  6765. When run as a service, `mysqld' has no access to a console window, so
  6766. no messages can be seen there.  If `mysqld' doesn't start, check the
  6767. error log to see whether the server wrote any messages there to
  6768. indicate the cause of the problem.  The error log is located in the
  6769. `C:\mysql\data' directory. It is the file with a suffix of `.err'.
  6770.  
  6771. When `mysqld' is running as a service, it can be stopped by using the
  6772. `Services' utility, the command `NET STOP MySQL', or the command
  6773. `mysqladmin shutdown'. If the service is running when Windows shuts
  6774. down, Windows will stop the server automatically.
  6775.  
  6776. From MySQL 3.23.44 on, you have the choice of installing the server as
  6777. a `Manual' service if you don't wish the service to be started
  6778. automatically during the boot process. To do this, use the
  6779. `--install-manual' option rather than the `--install' option:
  6780.  
  6781.      C:\> C:\mysql\bin\mysqld --install-manual
  6782.  
  6783. To remove a server that is installed as a service, first stop it if it
  6784. is running. Then use the `--remove' option to remove it:
  6785.  
  6786.      C:\> C:\mysql\bin\mysqld --remove
  6787.  
  6788. For MySQL versions older than 3.23.49, one problem with automatic MySQL
  6789. service shutdown is that Windows waited only for a few seconds for the
  6790. shutdown to complete, then killed the database server process if the
  6791. time limit was exceeded. This had the potential to cause problems.
  6792. (For example, the `InnoDB' storage engine had to perform crash recovery
  6793. at the next startup.) Starting from MySQL 3.23.49, Windows waits longer
  6794. for the MySQL server shutdown to complete. If you notice this still is
  6795. not enough for your installation, it is safest not to run the MySQL
  6796. server as a service. Instead, start it from the command-line prompt,
  6797. and stop it with `mysqladmin shutdown'.
  6798.  
  6799. This change to tell Windows to wait longer when stopping the MySQL
  6800. server works for Windows 2000 and XP. It does not work for Windows NT,
  6801. where Windows waits only 20 seconds for a service to shut down, and
  6802. after that kills the service process. You can increase this default by
  6803. opening the Registry Editor `\winnt\system32\regedt32.exe' and editing
  6804. the value of `WaitToKillServiceTimeout' at
  6805. `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control' in the Registry
  6806. tree. Specify the new larger value in milliseconds.  For example, the
  6807. value 120000 tells Windows NT to wait up to 120 seconds.
  6808.  
  6809. If you don't want to start `mysqld' as a service, you can start it from
  6810. the command line.  For instructions, see *Note Win95 start::.
  6811.  
  6812. Please see *Note Windows troubleshooting:: if you encounter
  6813. difficulties during installation.
  6814.  
  6815. Troubleshooting a MySQL Installation Under Windows
  6816. ..................................................
  6817.  
  6818. When installing and running MySQL for the first time, you may encounter
  6819. certain errors that prevent the MySQL server from starting.  The
  6820. purpose of this section is to help you diagnose and correct some of
  6821. these errors.
  6822.  
  6823. Your first resource when troubleshooting server issues is the error log.
  6824. The MySQL server uses the error log to record information relevant to
  6825. the error that is preventing the server from starting. The error log is
  6826. located in the data directory specified in your `my.ini' file.  The
  6827. default data directory location is `C:\mysql\data'.  *Note Error log::.
  6828.  
  6829. Another source of information regarding possible errors is the console
  6830. messages displayed when the MySQL service is starting. Use the `NET
  6831. START mysql' command from the command line after installing `mysqld' as
  6832. a service to see any error messages regarding the starting of the MySQL
  6833. server as a service.  *Note NT start::.
  6834.  
  6835. The following are examples of some of the more common error messages
  6836. you may encounter when installing MySQL and starting the server for the
  6837. first time:
  6838.  
  6839.      System error 1067 has occurred.
  6840.      Fatal error: Can't open privilege tables: Table 'mysql.host' doesn't exist
  6841.  
  6842. These messages occur when the MySQL server cannot find the `mysql'
  6843. privileges database or other critical files. This error is often
  6844. encountered when the MySQL base or data directories are installed in
  6845. different locations than the default locations (`C:\mysql' and
  6846. `C:\mysql\data', respectively).
  6847.  
  6848. If you have installed MySQL to a directory other than `C:\mysql' you
  6849. will need to ensure that the MySQL server is aware of this through the
  6850. use of a configuration (`my.ini') file. The `my.ini' file needs to be
  6851. located in your Windows directory, typically located at `C:\WinNT' or
  6852. `C:\WINDOWS'. You can determine its exact location from the value of
  6853. the `WINDIR' environment variable by issuing the following command from
  6854. the command prompt:
  6855.  
  6856.      C:\> echo %WINDIR%
  6857.  
  6858. An option file can be created and modified with any text editor, such
  6859. as the Notepad program. For example, if MySQL is installed at
  6860. `E:\mysql' and the data directory is located at `D:\MySQLdata', you can
  6861. create the option file and set up a `[mysqld]' section to specify
  6862. values for the basedir and datadir parameters:
  6863.  
  6864.      [mysqld]
  6865.      # set basedir to your installation path
  6866.      basedir=E:/mysql
  6867.      # set datadir to the location of your data directory
  6868.      datadir=D:/MySQLdata
  6869.  
  6870. Note that Windows pathnames are specified in option files using forward
  6871. slashes rather than backslashes. If you do use backslashes, you must
  6872. double them:
  6873.  
  6874.      [mysqld]
  6875.      # set basedir to your installation path
  6876.      basedir=C:\\Program Files\\mysql
  6877.      # set datadir to the location of your data directory
  6878.      datadir=D:\\MySQLdata
  6879. *Note Windows prepare environment::.
  6880.  
  6881. Running MySQL Client Programs on Windows
  6882. ........................................
  6883.  
  6884. You can test whether the MySQL server is working by executing any of the
  6885. following commands:
  6886.  
  6887.      C:\> C:\mysql\bin\mysqlshow
  6888.      C:\> C:\mysql\bin\mysqlshow -u root mysql
  6889.      C:\> C:\mysql\bin\mysqladmin version status proc
  6890.      C:\> C:\mysql\bin\mysql test
  6891.  
  6892. If `mysqld' is slow to respond to TCP/IP connections from client
  6893. programs on Windows 9x/Me, there is probably a problem with your DNS.
  6894. In this case, start `mysqld' with the `--skip-name-resolve' option and
  6895. use only `localhost' and IP numbers in the `Host' column of the MySQL
  6896. grant tables.
  6897.  
  6898. You can force a MySQL client to use a named pipe connection rather than
  6899. TCP/IP  by specifying the `--pipe' option or by specifying `.' (period)
  6900. as the host name.  Use the `--socket' option to specify the name of the
  6901. pipe.  As of MySQL 4.1, you should use the `--protocol=PIPE' option.
  6902.  
  6903. There are two versions of the MySQL command-line tool:
  6904. *Binary*       *Description*
  6905. `mysql'        Compiled on native Windows, offering limited text editing
  6906.                capabilities.
  6907. `mysqlc'       Compiled with the Cygnus GNU compiler and libraries,
  6908.                which offers `readline' editing.
  6909.  
  6910. If you want to use `mysqlc', you must have a copy of the
  6911. `cygwinb19.dll' library installed somewhere that `mysqlc' can find it.
  6912. Current distributions of MySQL include this library in the same
  6913. directory as `mysqlc' (the `bin' directory under the base directory of
  6914. your MySQL installation). If your distribution does not have the
  6915. `cygwinb19.dll' library in the `bin' directory, look for it in the
  6916. `lib' directory and copy it to your Windows system directory
  6917. (`\Windows\system' or a similar place).
  6918.  
  6919. MySQL on Windows Compared to MySQL on Unix
  6920. ..........................................
  6921.  
  6922. MySQL for Windows has by now proven itself to be very stable. The
  6923. Windows version of MySQL has the same features as the corresponding
  6924. Unix version, with the following exceptions:
  6925.  
  6926. *Windows 95 and threads*
  6927.      Windows 95 leaks about 200 bytes of main memory for each thread
  6928.      creation.  Each connection in MySQL creates a new thread, so you
  6929.      shouldn't run `mysqld' for an extended time on Windows 95 if your
  6930.      server handles many connections!  Other versions of Windows don't
  6931.      suffer from this bug.
  6932.  
  6933. *Limited number of ports*
  6934.      Windows systems have about 4,000 ports available for client
  6935.      connections, and after a connection on a port closes, it takes two
  6936.      to four minutes before the port can be reused.  In situations
  6937.      where clients connect to and disconnect from the server at a high
  6938.      rate, it is possible for all available ports to be used up before
  6939.      closed ports become available again. If this happens, the MySQL
  6940.      server will appear to have become unresponsive even though it is
  6941.      running.  Note that ports may be used by other applications
  6942.      running on the machine as well, in which case the number of ports
  6943.      available to MySQL is lower.
  6944.  
  6945.      For more information, see
  6946.      `http://support.microsoft.com/default.aspx?scid=kb;en-us;196271'.
  6947.  
  6948. *Concurrent reads*
  6949.      MySQL depends on the `pread()' and `pwrite()' calls to be able to
  6950.      mix `INSERT' and `SELECT'.  Currently we use mutexes to emulate
  6951.      `pread()'/`pwrite()'.  We will, in the long run, replace the file
  6952.      level interface with a virtual interface so that we can use the
  6953.      `readfile()'/`writefile()' interface on NT, 2000, and XP to get
  6954.      more speed.  The current implementation limits the number of open
  6955.      files MySQL can use to 2,048 (1,024 before MySQL 4.0.19), which
  6956.      means that you will not be able to run as many concurrent threads
  6957.      on NT, 2000, and XP as on Unix.
  6958.  
  6959. *Blocking read*
  6960.      MySQL uses a blocking read for each connection, which has the
  6961.      following implications if named pipe connections are enabled:
  6962.  
  6963.         * A connection will not be disconnected automatically after
  6964.           eight hours, as happens with the Unix version of MySQL.
  6965.  
  6966.         * If a connection hangs, it's impossible to break it without
  6967.           killing MySQL.
  6968.  
  6969.         * `mysqladmin kill' will not work on a sleeping connection.
  6970.  
  6971.         * `mysqladmin shutdown' can't abort as long as there are
  6972.           sleeping connections.
  6973.  
  6974.      We plan to fix this problem when our Windows developers have
  6975.      figured out a nice workaround.
  6976.  
  6977. *`ALTER TABLE'*
  6978.      While you are executing an `ALTER TABLE' statement, the table is
  6979.      locked from being used by other threads.  This has to do with the
  6980.      fact that on Windows, you can't delete a file that is in use by
  6981.      another thread.  In the future, we may find some way to work
  6982.      around this problem.
  6983.  
  6984. *`DROP TABLE'*
  6985.      `DROP TABLE' on a table that is in use by a `MERGE' table will not
  6986.      work on Windows because the `MERGE' handler does the table mapping
  6987.      hidden from the upper layer of MySQL.  Because Windows doesn't
  6988.      allow you to drop files that are open, you first must flush all
  6989.      `MERGE' tables (with `FLUSH TABLES') or drop the `MERGE' table
  6990.      before dropping the table.  We will fix this at the same time we
  6991.      introduce views.
  6992.  
  6993. *`DATA DIRECTORY' and `INDEX DIRECTORY'*
  6994.      The `DATA DIRECTORY' and `INDEX DIRECTORY' options for `CREATE
  6995.      TABLE' are ignored on Windows, because Windows doesn't support
  6996.      symbolic links.  These options also are ignored on systems that
  6997.      have a non-functional `realpath()' call.
  6998.  
  6999. *`DROP DATABASE'*
  7000.      You cannot drop a database that is in use by some thread.
  7001.  
  7002. *Killing MySQL from the Task Manager*
  7003.      You cannot kill MySQL from the Task Manager or with the shutdown
  7004.      utility in Windows 95.  You must take it down with `mysqladmin
  7005.      shutdown'.
  7006.  
  7007. *Case-insensitive names*
  7008.      Filenames are not case sensitive on Windows, so MySQL database and
  7009.      table names are also not case sensitive on Windows.  The only
  7010.      restriction is that database and table names must be specified
  7011.      using the same case throughout a given statement.  *Note Name case
  7012.      sensitivity::.
  7013.  
  7014. *The `\' pathname separator character*
  7015.      Pathname components in Windows 95 are separated by the `\'
  7016.      character, which is also the escape character in MySQL.  If you
  7017.      are using `LOAD DATA INFILE' or `SELECT ... INTO OUTFILE', use
  7018.      Unix-style filenames with `/' characters:
  7019.  
  7020.           mysql> LOAD DATA INFILE 'C:/tmp/skr.txt' INTO TABLE skr;
  7021.           mysql> SELECT * INTO OUTFILE 'C:/tmp/skr.txt' FROM skr;
  7022.  
  7023.      Alternatively, you must double the `\' character:
  7024.  
  7025.           mysql> LOAD DATA INFILE 'C:\\tmp\\skr.txt' INTO TABLE skr;
  7026.           mysql> SELECT * INTO OUTFILE 'C:\\tmp\\skr.txt' FROM skr;
  7027.  
  7028. *Problems with pipes.*
  7029.      Pipes do not work reliably from the Windows command-line prompt.
  7030.      If the pipe includes the character `^Z' / `CHAR(24)', Windows will
  7031.      think it has encountered end-of-file and abort the program.
  7032.  
  7033.      This is mainly a problem when you try to apply a binary log as
  7034.      follows:
  7035.  
  7036.           C:\> mysqlbinlog binary-log-name | mysql --user=root
  7037.  
  7038.      If you have a problem applying the log and suspect that it is
  7039.      because of a `^Z' / `CHAR(24)' character, you can use the
  7040.      following workaround:
  7041.  
  7042.           C:\> mysqlbinlog binary-log-file --result-file=/tmp/bin.sql
  7043.           C:\> mysql --user=root --execute "source /tmp/bin.sql"
  7044.  
  7045.      The latter command also can be used to reliably read in any SQL
  7046.      file that may contain binary data.
  7047.  
  7048. *`Can't open named pipe' error*
  7049.      If you use a MySQL 3.22 server on Windows NT with the newest MySQL
  7050.      client programs, you will get the following error:
  7051.  
  7052.           error 2017: can't open named pipe to host: . pipe...
  7053.  
  7054.      This happens because the release version of MySQL uses named pipes
  7055.      on NT by default.  You can avoid this error by using the
  7056.      `--host=localhost' option to the new MySQL clients or by creating
  7057.      an option file `C:\my.cnf' that contains the following information:
  7058.  
  7059.           [client]
  7060.           host = localhost
  7061.  
  7062.      Starting from 3.23.50, named pipes are enabled only if `mysqld-nt'
  7063.      or `mysqld-max-nt' is started with `--enable-named-pipe'.
  7064.  
  7065. *`Access denied for user' error*
  7066.      If you attempt to run a MySQL client program to connect to a server
  7067.      running on the same machine, but get the error `Access denied for
  7068.      user 'SOME-USER'@'unknown' to database 'mysql'', this means that
  7069.      MySQL cannot resolve your hostname properly.
  7070.  
  7071.      To fix this, you should create a file named `\windows\hosts'
  7072.      containing the following information:
  7073.  
  7074.           127.0.0.1       localhost
  7075.  
  7076. Here are some open issues for anyone who might want to help us improve
  7077. MySQL on Windows:
  7078.  
  7079.    * Add some nice start and shutdown icons to the MySQL installation.
  7080.  
  7081.    * It would be really nice to be able to kill `mysqld' from the Task
  7082.      Manager in Windows 95.  For the moment, you must use `mysqladmin
  7083.      shutdown'.
  7084.  
  7085.    * Port `readline' to Windows for use in the `mysql' command-line
  7086.      tool.
  7087.  
  7088.    * GUI versions of the standard MySQL clients (`mysql', `mysqlshow',
  7089.      `mysqladmin', and `mysqldump') would be nice.
  7090.  
  7091.    * It would be nice if the socket read and write functions in `net.c'
  7092.      were interruptible. This would make it possible to kill open
  7093.      threads with `mysqladmin kill' on Windows.
  7094.  
  7095.    * Add macros to use the faster thread-safe increment/decrement
  7096.      methods provided by Windows.
  7097.  
  7098. Installing MySQL on Linux
  7099. -------------------------
  7100.  
  7101. The recommended way to install MySQL on Linux is by using the RPM
  7102. packages. The MySQL RPMs are currently built on a SuSE Linux 7.3
  7103. system, but should work on most versions of Linux that support `rpm'
  7104. and use `glibc'.  To obtain RPM packages, see *Note Getting MySQL::.
  7105.  
  7106. *Note*: RPM distributions of MySQL often are provided by other vendors.
  7107. Be aware that they may differ in features and capabilities from those
  7108. built by MySQL AB, and that the instructions in this manual do not
  7109. necessarily apply to installing them. The vendor's instructions should
  7110. be consulted instead.
  7111.  
  7112. If you have problems with an RPM file (for example, if you receive the
  7113. error "`Sorry, the host 'XXXX' could not be looked up'"), see *Note
  7114. Binary notes-Linux::.
  7115.  
  7116. In most cases, you only need to install the `MySQL-server' and
  7117. `MySQL-client' packages to get a functional MySQL installation. The
  7118. other packages are not required for a standard installation.  If you
  7119. want to run a MySQL-Max server that has additional capabilities, you
  7120. should also install the `MySQL-Max' RPM. However, you should do so only
  7121. _ after_ installing the `MySQL-server' RPM.  *Note `mysqld-max':
  7122. mysqld-max.
  7123.  
  7124. If you get a dependency failure when trying to install the MySQL 4.0
  7125. packages (for example, "`error: removing these packages would break
  7126. dependencies: libmysqlclient.so.10 is needed by ...'"), you should also
  7127. install the package `MySQL-shared-compat', which includes both the
  7128. shared libraries for backward compatibility (`libmysqlclient.so.12' for
  7129. MySQL 4.0 and `libmysqlclient.so.10' for MySQL 3.23).
  7130.  
  7131. Many Linux distributions still ship with MySQL 3.23 and they usually
  7132. link applications dynamically to save disk space. If these shared
  7133. libraries are in a separate package (for example, `MySQL-shared'), it is
  7134. sufficient to simply leave this package installed and just upgrade the
  7135. MySQL server and client packages (which are statically linked and do
  7136. not depend on the shared libraries). For distributions that include the
  7137. shared libraries in the same package as the MySQL server (for example,
  7138. Red Hat Linux), you could either install our 3.23 `MySQL-shared' RPM,
  7139. or use the `MySQL-shared-compat' package instead.
  7140.  
  7141. The following RPM packages are available:
  7142.  
  7143.    * `MySQL-server-VERSION.i386.rpm'
  7144.  
  7145.      The MySQL server.  You will need this unless you only want to
  7146.      connect to a MySQL server running on another machine. Note: Server
  7147.      RPM files were called `MySQL-VERSION.i386.rpm' before MySQL
  7148.      4.0.10. That is, they did not have `-server' in the name.
  7149.  
  7150.    * `MySQL-Max-VERSION.i386.rpm'
  7151.  
  7152.      The MySQL-Max server. This server has additional capabilities that
  7153.      the one provided in the `MySQL-server' RPM does not.  You must
  7154.      install the `MySQL-server' RPM first, because the `MySQL-Max' RPM
  7155.      depends on it.
  7156.  
  7157.    * `MySQL-client-VERSION.i386.rpm'
  7158.  
  7159.      The standard MySQL client programs. You probably always want to
  7160.      install this package.
  7161.  
  7162.    * `MySQL-bench-VERSION.i386.rpm'
  7163.  
  7164.      Tests and benchmarks. Requires Perl and the `DBD::mysql' module.
  7165.  
  7166.    * `MySQL-devel-VERSION.i386.rpm'
  7167.  
  7168.      The libraries and include files that are needed if you want to
  7169.      compile other MySQL clients, such as the Perl modules.
  7170.  
  7171.    * `MySQL-shared-VERSION.i386.rpm'
  7172.  
  7173.      This package contains the shared libraries (`libmysqlclient.so*')
  7174.      that certain languages and applications need to dynamically load
  7175.      and use MySQL.
  7176.  
  7177.    * `MySQL-shared-compat-VERSION.i386.rpm'
  7178.  
  7179.      This package includes the shared libraries for both MySQL 3.23 and
  7180.      MySQL 4.0. Install this package instead of `MySQL-shared' if you
  7181.      have applications installed that are dynamically linked against
  7182.      MySQL 3.23 but you want to upgrade to MySQL 4.0 without breaking
  7183.      the library dependencies. This package has been available since
  7184.      MySQL 4.0.13.
  7185.  
  7186.    * `MySQL-embedded-VERSION.i386.rpm'
  7187.  
  7188.      The embedded MySQL server library (from MySQL 4.0).
  7189.  
  7190.    * `MySQL-VERSION.src.rpm'
  7191.  
  7192.      This contains the source code for all of the previous packages. It
  7193.      can also be used to rebuild the RPMs on other architectures (for
  7194.      example, Alpha or SPARC).
  7195.  
  7196. To see all files in an RPM package (for example, a `MySQL-server' RPM),
  7197. run:
  7198.  
  7199.      shell> rpm -qpl MySQL-server-VERSION.i386.rpm
  7200.  
  7201. To perform a standard minimal installation, run:
  7202.  
  7203.      shell> rpm -i MySQL-server-VERSION.i386.rpm
  7204.      shell> rpm -i MySQL-client-VERSION.i386.rpm
  7205.  
  7206. To install just the client package, run:
  7207.  
  7208.      shell> rpm -i MySQL-client-VERSION.i386.rpm
  7209.  
  7210. RPM provides a feature to verify the integrity and authenticity of
  7211. packages before installing them. If you would like to learn more about
  7212. this feature, see *Note Verifying Package Integrity::.
  7213.  
  7214. The server RPM places data under the `/var/lib/mysql' directory. The
  7215. RPM also creates a login account for a user named `mysql' (if one does
  7216. not already exist) to use for running the MySQL server, and creates the
  7217. appropriate entries in `/etc/init.d/' to start the server automatically
  7218. at boot time. (This means that if you have performed a previous
  7219. installation and have made changes to its startup script, you may want
  7220. to make a copy of the script so that you don't lose it when you install
  7221. a newer RPM.) See *Note Automatic start:: for more information on how
  7222. MySQL can be started automatically on system startup.
  7223.  
  7224. If you want to install the MySQL RPM on older Linux distributions that
  7225. do not support initialization scripts in `/etc/init.d' (directly or via
  7226. a symlink), you should create a symbolic link that points to the
  7227. location where your initialization scripts actually are installed. For
  7228. example, if that location is `/etc/rc.d/init.d', use these commands
  7229. before installing the RPM to create `/etc/init.d' as a symbolic link
  7230. that points there:
  7231.  
  7232.      shell> cd /etc
  7233.      shell> ln -s rc.d/init.d .
  7234.  
  7235. However, all current major Linux distributions should already support
  7236. the new directory layout that uses `/etc/init.d', because it is
  7237. required for LSB (Linux Standard Base) compliance.
  7238.  
  7239. If the RPM files that you install include `MySQL-server', the `mysqld'
  7240. server should be up and running after installation.  You should now be
  7241. able to start using MySQL.
  7242.  
  7243. If something goes wrong, you can find more information in the binary
  7244. installation section. *Note Installing binary::.
  7245.  
  7246. *Note*: The accounts that are listed in the MySQL grant tables
  7247. initially have no passwords.  After starting the server, you should set
  7248. up passwords for them using the instructions in *Note
  7249. Post-installation::.
  7250.  
  7251. Installing MySQL on Mac OS X
  7252. ----------------------------
  7253.  
  7254. Beginning with MySQL 4.0.11, you can install MySQL on Mac OS X 10.2.x
  7255. ("Jaguar") and up using a Mac OS X binary package in PKG format instead
  7256. of the binary tarball distribution. Please note that older versions of
  7257. Mac OS X (for example, 10.1.x) are not supported by this package.
  7258.  
  7259. The package is located inside a disk image (`.dmg') file that you first
  7260. need to mount by double-clicking its icon in the Finder. It should then
  7261. mount the image and display its contents.
  7262.  
  7263. To obtain MySQL, see *Note Getting MySQL::.
  7264.  
  7265. *Note*: Before proceeding with the installation, be sure to shut down
  7266. all running MySQL server instances by either using the MySQL Manager
  7267. Application (on Mac OS X Server) or via `mysqladmin shutdown' on the
  7268. command line.
  7269.  
  7270. To actually install the MySQL PKG file, double-click on the package
  7271. icon. This launches the Mac OS X Package Installer, which will guide
  7272. you through the installation of MySQL.
  7273.  
  7274. Due to a bug in the Mac OS X package installer, you may see this error
  7275. message in the destination disk selection dialog:
  7276.  
  7277.      You cannot install this software on this disk. (null)
  7278.  
  7279. If this error occurs, simply click the `Go Back' button once to return
  7280. to the previous screen. Then click `Continue' to advance to the
  7281. destination disk selection again, and you should be able to choose the
  7282. destination disk correctly. We have reported this bug to Apple and it is
  7283. investigating this problem.
  7284.  
  7285. The Mac OS X PKG of MySQL will install itself into
  7286. `/usr/local/mysql-VERSION' and will also install a symbolic link,
  7287. `/usr/local/mysql', pointing to the new location. If a directory named
  7288. `/usr/local/mysql' already exists, it will be renamed to
  7289. `/usr/local/mysql.bak' first. Additionally, the installer will create
  7290. the grant tables in the `mysql' database by executing `mysql_install_db'
  7291. after the installation.
  7292.  
  7293. The installation layout is similar to that of a `tar' file binary
  7294. distribution; all MySQL binaries are located in the directory
  7295. `/usr/local/mysql/bin'.  The MySQL socket file is created as
  7296. `/tmp/mysql.sock' by default.  *Note Installation layouts::.
  7297.  
  7298. MySQL installation requires a Mac OS X user account named `mysql'.  A
  7299. user account with this name should exist by default on Mac OS X 10.2
  7300. and up.
  7301.  
  7302. If you are running Mac OS X Server, you already have a version of MySQL
  7303. installed.  The versions of MySQL that ship with Mac OS X Server
  7304. versions are shown in the following table:
  7305.  
  7306. *Mac OS X Server       *MySQL Version*
  7307. Version*               
  7308. 10.2-10.2.2            3.23.51
  7309. 10.2.3-10.2.6          3.23.53
  7310. 10.3                   4.0.14
  7311. 10.3.2                 4.0.16
  7312.  
  7313. This manual section covers the installation of the official MySQL Mac
  7314. OS X PKG only.  Make sure to read Apple's help information about
  7315. installing MySQL: Run the "Help View" application, select "Mac OS X
  7316. Server" help, do a search for "MySQL," and read the item entitled
  7317. "Installing MySQL."
  7318.  
  7319. For pre-installed versions of MySQL on Mac OS X Server, note especially
  7320. that you should start `mysqld' with `safe_mysqld' instead of
  7321. `mysqld_safe' if MySQL is older than version 4.0.
  7322.  
  7323. If you previously used Marc Liyanage's MySQL packages for Mac OS X from
  7324. `http://www.entropy.ch', you can simply follow the update instructions
  7325. for packages using the binary installation layout as given on his pages.
  7326.  
  7327. If you are upgrading from Marc's 3.23.xx versions or from the Mac OS X
  7328. Server version of MySQL to the official MySQL PKG, you also need to
  7329. convert the existing MySQL privilege tables to the current format,
  7330. because some new security privileges have been added.  *Note
  7331. Upgrading-grant-tables::.
  7332.  
  7333. If you would like to automatically start up MySQL during system
  7334. startup, you also need to install the MySQL Startup Item. Starting with
  7335. MySQL 4.0.15, it is part of the Mac OS X installation disk images as a
  7336. separate installation package. Simply double-click the
  7337. `MySQLStartupItem.pkg' icon and follow the instructions to install it.
  7338.  
  7339. Note that the Startup Item need be installed only once! There is no
  7340. need to install it each time you upgrade the MySQL package later.
  7341.  
  7342. The Startup Item will be installed into
  7343. `/Library/StartupItems/MySQLCOM'.  (Before MySQL 4.1.2, the location
  7344. was `/Library/StartupItems/MySQL', but that collided with the MySQL
  7345. Startup Item installed by Mac OS X Server.)  Startup Item installation
  7346. adds a variable `MYSQLCOM=-YES-' to the system configuration file
  7347. `/etc/hostconfig'. If you would like to disable the automatic startup
  7348. of MySQL, simply change this variable to `MYSQLCOM=-NO-'.
  7349.  
  7350. On Mac OS X Server, the default MySQL installation uses the variable
  7351. `MYSQL' in the `/etc/hostconfig' file.  The MySQL AB Startup Item
  7352. installer disables this variable by setting it to `MYSQL=-NO-'. This
  7353. avoids boot time conflicts with the `MYSQLCOM' variable used by the
  7354. MySQL AB Startup Item.  However, it does not shut down an already
  7355. running MySQL server. You should do that yourself.
  7356.  
  7357. After the installation, you can start up MySQL by running the following
  7358. commands in a terminal window. You must have administrator privileges to
  7359. perform this task.
  7360.  
  7361. If you have installed the Startup Item:
  7362.  
  7363.      shell> sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
  7364.      (Enter your password, if necessary)
  7365.      (Press Control-D or enter "exit" to exit the shell)
  7366.  
  7367. For versions of MySQL older than 4.1.3, substitute
  7368. `/Library/StartupItems/MySQLCOM/MySQLCOM' with
  7369. `/Library/StartupItems/MySQL/MySQL' above.
  7370.  
  7371. If you don't use the Startup Item, enter the following command sequence:
  7372.  
  7373.      shell> cd /usr/local/mysql
  7374.      shell> sudo ./bin/mysqld_safe
  7375.      (Enter your password, if necessary)
  7376.      (Press Control-Z)
  7377.      shell> bg
  7378.      (Press Control-D or enter "exit" to exit the shell)
  7379.  
  7380. You should now be able to connect to the MySQL server, for example, by
  7381. running `/usr/local/mysql/bin/mysql'.
  7382.  
  7383. *Note*: The accounts that are listed in the MySQL grant tables
  7384. initially have no passwords.  After starting the server, you should set
  7385. up passwords for them using the instructions in *Note
  7386. Post-installation::.
  7387.  
  7388. You might want to add aliases to your shell's resource file to make it
  7389. easier to access commonly used programs such as `mysql' and `mysqladmin'
  7390. from the command line. The syntax for `tcsh' is:
  7391.  
  7392.      alias mysql /usr/local/mysql/bin/mysql
  7393.      alias mysqladmin /usr/local/mysql/bin/mysqladmin
  7394.  
  7395. For `bash', use:
  7396.  
  7397.      alias mysql=/usr/local/mysql/bin/mysql
  7398.      alias mysqladmin=/usr/local/mysql/bin/mysqladmin
  7399.  
  7400. Even better, add `/usr/local/mysql/bin' to your `PATH' environment
  7401. variable. For example, add the following line to your `$HOME/.tcshrc'
  7402. file if your shell is `tcsh':
  7403.  
  7404.      setenv PATH ${PATH}:/usr/local/mysql/bin
  7405.  
  7406. If no `.tcshrc' file exists in your home directory, create it with a
  7407. text editor.
  7408.  
  7409. If you are upgrading an existing installation, please note that
  7410. installing a new MySQL PKG does not remove the directory of an older
  7411. installation. Unfortunately, the Mac OS X Installer does not yet offer
  7412. the functionality required to properly upgrade previously installed
  7413. packages.
  7414.  
  7415. To use your existing databases with the new installation, you'll need
  7416. to copy the contents of the old data directory to the new data
  7417. directory. Make sure that neither the old server nor the new one is
  7418. running when you do this.  After you have copied over the MySQL
  7419. database files from the previous installation and have successfully
  7420. started the new server, you should consider removing the old
  7421. installation files to save disk space.  Additionally, you should also
  7422. remove older versions of the Package Receipt directories located in
  7423. `/Library/Receipts/mysql-VERSION.pkg'.
  7424.  
  7425. Installing MySQL on NetWare
  7426. ---------------------------
  7427.  
  7428. Porting MySQL to NetWare was an effort spearheaded by Novell. Novell
  7429. customers will be pleased to note that NetWare 6.5 ships with bundled
  7430. MySQL binaries, complete with an automatic commercial use license for
  7431. all servers running that version of NetWare.
  7432.  
  7433. MySQL for NetWare is compiled using a combination of `Metrowerks
  7434. CodeWarrior for NetWare' and special cross-compilation versions of the
  7435. GNU autotools.
  7436.  
  7437. The latest binary packages for NetWare can be obtained at
  7438. `http://dev.mysql.com/downloads/'.  *Note Getting MySQL::.
  7439.  
  7440. In order to host MySQL, the NetWare server must meet these requirements:
  7441.  
  7442.    * NetWare 6.5 Support Pack 2 installed and updated with the latest
  7443.      LibC, or NetWare 6.0 with Support Pack 4 installed and updated
  7444.      with the latest LibC.  NetWare 6.5 Support Pack 2 and other
  7445.      updates are available at
  7446.      `http://support.novell.com/filefinder/18197/index.html'.  NetWare
  7447.      6.0 Support Pack 4 and other updates are available at
  7448.      `http://support.novell.com/filefinder/13659/index.html'.  The
  7449.      latest LibC is available at
  7450.      `http://developer.novell.com/ndk/libc.htm'.  Steps to update LibC
  7451.      can be found here:
  7452.      `http://developer.novell.com/ndk/doc/libc/index.html?page=/ndk/doc/libc/libc_enu/data/ajjl0r0.html'
  7453.  
  7454.    * The system must meet Novell's minimum requirements to run the
  7455.      respective version of NetWare.
  7456.  
  7457.    * MySQL data, as well as the binaries themselves, must be installed
  7458.      on an NSS volume; traditional volumes are not supported.
  7459.  
  7460. To install MySQL for NetWare, use the following procedure:
  7461.  
  7462.   1. If you are upgrading from a prior installation, stop the MySQL
  7463.      server.  This is done from the server console, using the following
  7464.      command:
  7465.  
  7466.           SERVER:  mysqladmin -u root shutdown
  7467.  
  7468.   2. Log on to the target server from a client machine with access to
  7469.      the location where you will install MySQL.
  7470.  
  7471.   3. Extract the binary package Zip file onto the server. Be sure to
  7472.      allow the paths in the Zip file to be used. It is safe to simply
  7473.      extract the file to `SYS:\'.
  7474.  
  7475.      If you are upgrading from a prior installation, you may need to
  7476.      copy the data directory (for example, `SYS:MYSQL\DATA') now, as
  7477.      well as `my.cnf', if you have customized it. You can then delete
  7478.      the old copy of MySQL.
  7479.  
  7480.   4. You might want to rename the directory to something more
  7481.      consistent and easy to use. We recommend using `SYS:MYSQL';
  7482.      examples in this manual use this name to refer to the installation
  7483.      directory in general.
  7484.  
  7485.   5. At the server console, add a search path for the directory
  7486.      containing the MySQL NLMs. For example:
  7487.  
  7488.           SERVER:  SEARCH ADD SYS:MYSQL\BIN
  7489.  
  7490.   6. Initialize the data directory and the grant tables, if needed, by
  7491.      executing `mysql_install_db' at the server console.
  7492.  
  7493.   7. Start the MySQL server using `mysqld_safe' at the server console.
  7494.  
  7495.   8. To finish the installation, you should also add the following
  7496.      commands to `autoexec.ncf'. For example, if your MySQL
  7497.      installation is in `SYS:MYSQL' and you want MySQL to start
  7498.      automatically, you could add these lines:
  7499.  
  7500.           #Starts the MySQL 4.0.x database server
  7501.           SEARCH ADD SYS:MYSQL\BIN
  7502.           MYSQLD_SAFE
  7503.  
  7504.      If you are running MySQL on NetWare 6.0, we strongly suggest that
  7505.      you use the `--skip-external-locking' option on the command line:
  7506.  
  7507.           #Starts the MySQL 4.0.x database server
  7508.           SEARCH ADD SYS:MYSQL\BIN
  7509.           MYSQLD_SAFE --skip-external-locking
  7510.  
  7511.      It will also be necessary to use `CHECK TABLE' and `REPAIR TABLE'
  7512.      instead of `myisamchk', because `myisamchk' makes use of external
  7513.      locking.  External locking is known to have problems on NetWare
  7514.      6.0; the problem has been eliminated in NetWare 6.5.
  7515.  
  7516.      `mysqld_safe' on NetWare provides a screen presence. When you
  7517.      unload (shut down) the `mysqld_safe' NLM, the screen does not by
  7518.      default go away.  Instead, it prompts for user input:
  7519.  
  7520.           *<NLM has terminated; Press any key to close the screen>*
  7521.  
  7522.      If you want NetWare to close the screen automatically instead, use
  7523.      the `--autoclose' option to `mysqld_safe'. For example:
  7524.  
  7525.           #Starts the MySQL 4.0.x database server
  7526.           SEARCH ADD SYS:MYSQL\BIN
  7527.           MYSQLD_SAFE --autoclose
  7528.  
  7529.   9. The latest Netware Perl and PHP modules for MySQL can be
  7530.      downloaded from `http://developer.novell.com/ndk/perl5.htm' and
  7531.      `http://developer.novell.com/ndk/php2.htm' respectively.
  7532.  
  7533.  
  7534. The behavior of `mysqld_safe' on NetWare is described further in *Note
  7535. `mysqld_safe': mysqld_safe.
  7536.  
  7537. If there was an existing installation of MySQL on the server, be sure
  7538. to check for existing MySQL startup commands in `autoexec.ncf', and
  7539. edit or delete them as necessary.
  7540.  
  7541. *Note*: The accounts that are listed in the MySQL grant tables
  7542. initially have no passwords.  After starting the server, you should set
  7543. up passwords for them using the instructions in *Note
  7544. Post-installation::.
  7545.  
  7546. Installing MySQL on Other Unix-Like Systems
  7547. -------------------------------------------
  7548.  
  7549. This section covers the installation of MySQL binary distributions that
  7550. are provided for various platforms in the form of compressed `tar' files
  7551. (files with a `.tar.gz' extension).  See *Note MySQL binaries:: for a
  7552. detailed list.
  7553.  
  7554. To obtain MySQL, see *Note Getting MySQL::.
  7555.  
  7556. MySQL `tar' file binary distributions have names of the form
  7557. `mysql-VERSION-OS.tar.gz', where `VERSION' is a number (for example,
  7558. `4.0.17'), and OS indicates the type of operating system for which the
  7559. distribution is intended (for example, `pc-linux-i686').
  7560.  
  7561. In addition to these generic packages, we also offer binaries in
  7562. platform-specific package formats for selected platforms.  See *Note
  7563. Quick Standard Installation:: for more information on how to install
  7564. these.
  7565.  
  7566. You need the following tools to install a MySQL `tar' file binary
  7567. distribution:
  7568.  
  7569.    * GNU `gunzip' to uncompress the distribution.
  7570.  
  7571.    * A reasonable `tar' to unpack the distribution. GNU `tar' is known
  7572.      to work. Some operating systems come with a pre-installed version
  7573.      of `tar' that is known to have problems.  For example, Mac OS X
  7574.      `tar' and Sun `tar' are known to have problems with long
  7575.      filenames.  On Mac OS X, you can use the pre-installed `gnutar'
  7576.      program.  On other systems with a deficient `tar', you should
  7577.      install GNU `tar' first.
  7578.  
  7579. If you run into problems, _please always use `mysqlbug'_ when posting
  7580. questions to a MySQL mailing list.  Even if the problem isn't a bug,
  7581. `mysqlbug' gathers system information that will help others solve your
  7582. problem.  By not using `mysqlbug', you lessen the likelihood of getting
  7583. a solution to your problem.  You will find `mysqlbug' in the `bin'
  7584. directory after you unpack the distribution.  *Note Bug reports::.
  7585.  
  7586. The basic commands you must execute to install and use a MySQL binary
  7587. distribution are:
  7588.  
  7589.      shell> groupadd mysql
  7590.      shell> useradd -g mysql mysql
  7591.      shell> cd /usr/local
  7592.      shell> gunzip < /PATH/TO/MYSQL-VERSION-OS.tar.gz | tar xvf -
  7593.      shell> ln -s FULL-PATH-TO-MYSQL-VERSION-OS mysql
  7594.      shell> cd mysql
  7595.      shell> scripts/mysql_install_db --user=mysql
  7596.      shell> chown -R root  .
  7597.      shell> chown -R mysql data
  7598.      shell> chgrp -R mysql .
  7599.      shell> bin/mysqld_safe --user=mysql &
  7600.  
  7601. For versions of MySQL older than 4.0, substitute `bin/safe_mysqld' for
  7602. `bin/mysqld_safe' in the final command.
  7603.  
  7604. *Note*: This procedure does not set up any passwords for MySQL
  7605. accounts.  After following the procedure, proceed to *Note
  7606. Post-installation::.
  7607.  
  7608. A more detailed version of the preceding description for installing a
  7609. binary distribution follows:
  7610.  
  7611.   1. Add a login user and group for `mysqld' to run as:
  7612.  
  7613.           shell> groupadd mysql
  7614.           shell> useradd -g mysql mysql
  7615.  
  7616.      These commands add the `mysql' group and the `mysql' user.  The
  7617.      syntax for `useradd' and `groupadd' may differ slightly on
  7618.      different versions of Unix.  They may also be called `adduser' and
  7619.      `addgroup'.
  7620.  
  7621.      You might want to call the user and group something else instead
  7622.      of `mysql'.  If so, substitute the appropriate name in the
  7623.      following steps.
  7624.  
  7625.   2. Pick the directory under which you want to unpack the
  7626.      distribution, and change location into it. In the following
  7627.      example, we unpack the distribution under `/usr/local'. (The
  7628.      instructions, therefore, assume that you have permission to create
  7629.      files and directories in `/usr/local'.  If that directory is
  7630.      protected, you will need to perform the installation as `root'.)
  7631.  
  7632.           shell> cd /usr/local
  7633.  
  7634.   3. Obtain a distribution file from one of the sites listed in *Note
  7635.      Getting MySQL: Getting MySQL.  For a given release, binary
  7636.      distributions for all platforms are built from the same MySQL
  7637.      source distribution.
  7638.  
  7639.   4. Unpack the distribution, which will create the installation
  7640.      directory.  Then create a symbolic link to that directory:
  7641.  
  7642.           shell> gunzip < /PATH/TO/MYSQL-VERSION-OS.tar.gz | tar xvf -
  7643.           shell> ln -s FULL-PATH-TO-MYSQL-VERSION-OS mysql
  7644.  
  7645.      The `tar' command creates a directory named `mysql-VERSION-OS'.
  7646.      The `ln' command makes a symbolic link to that directory.  This
  7647.      lets you refer more easily to the installation directory as
  7648.      `/usr/local/mysql'.
  7649.  
  7650.      With GNU `tar', no separate invocation of `gunzip' is necessary.
  7651.      You can replace the first line with the following alternative
  7652.      command to uncompress and extract the distribution:
  7653.  
  7654.           shell> tar zxvf /PATH/TO/MYSQL-VERSION-OS.tar.gz
  7655.  
  7656.   5. Change location into the installation directory:
  7657.  
  7658.           shell> cd mysql
  7659.  
  7660.      You will find several files and subdirectories in the `mysql'
  7661.      directory.  The most important for installation purposes are the
  7662.      `bin' and `scripts' subdirectories.
  7663.  
  7664.     `bin'
  7665.           This directory contains client programs and the server.  You
  7666.           should add the full pathname of this directory to your `PATH'
  7667.           environment variable so that your shell finds the MySQL
  7668.           programs properly. *Note Environment variables::.
  7669.  
  7670.     `scripts'
  7671.           This directory contains the `mysql_install_db' script used to
  7672.           initialize the `mysql' database containing the grant tables
  7673.           that store the server access permissions.
  7674.  
  7675.   6. If you haven't installed MySQL before, you must create the MySQL
  7676.      grant tables:
  7677.  
  7678.           shell> scripts/mysql_install_db --user=mysql
  7679.  
  7680.      If you run the command as `root', you should use the `--user'
  7681.      option as shown.  The value of the option should be the name of
  7682.      the login account that you created in the first step to use for
  7683.      running the server.  If you run the command while logged in as
  7684.      that user, you can omit the `--user' option.
  7685.  
  7686.      Note that for MySQL versions older than 3.22.10,
  7687.      `mysql_install_db' left the server running after creating the grant
  7688.      tables.  This is no longer true; you will need to restart the
  7689.      server after performing the remaining steps in this procedure.
  7690.  
  7691.   7. Change the ownership of program binaries to `root' and ownership
  7692.      of the data directory to the user that you will run `mysqld' as.
  7693.      Assuming that you are located in the installation directory
  7694.      (`/usr/local/mysql'), the commands look like this:
  7695.  
  7696.           shell> chown -R root  .
  7697.           shell> chown -R mysql data
  7698.           shell> chgrp -R mysql .
  7699.  
  7700.      The first command changes the owner attribute of the files to the
  7701.      `root' user. The second changes the owner attribute of the data
  7702.      directory to the `mysql' user. The third changes the group
  7703.      attribute to the `mysql' group.
  7704.  
  7705.   8. If you would like MySQL to start automatically when you boot your
  7706.      machine, you can copy `support-files/mysql.server' to the location
  7707.      where your system has its startup files.  More information can be
  7708.      found in the `support-files/mysql.server' script itself and in
  7709.      *Note Automatic start::.
  7710.  
  7711.   9. You can set up new accounts using the `bin/mysql_setpermission'
  7712.      script if you install the `DBI' and `DBD::mysql' Perl modules.
  7713.      For instructions, see *Note Perl support::.
  7714.  
  7715.  10. If you would like to use `mysqlaccess' and have the MySQL
  7716.      distribution in some non-standard place, you must change the
  7717.      location where `mysqlaccess' expects to find the `mysql' client.
  7718.      Edit the `bin/mysqlaccess' script at approximately line 18.
  7719.      Search for a line that looks like this:
  7720.  
  7721.           $MYSQL     = '/usr/local/bin/mysql';    # path to mysql executable
  7722.  
  7723.      Change the path to reflect the location where `mysql' actually is
  7724.      stored on your system.  If you do not do this, you will get a
  7725.      `Broken pipe' error when you run `mysqlaccess'.
  7726.  
  7727.  
  7728. After everything has been unpacked and installed, you should test your
  7729. distribution.
  7730.  
  7731. You can start the MySQL server with the following command:
  7732.  
  7733.      shell> bin/mysqld_safe --user=mysql &
  7734.  
  7735. For versions of MySQL older than 4.0, substitute `bin/safe_mysqld' for
  7736. `bin/mysqld_safe' in the command.
  7737.  
  7738. More information about `mysqld_safe' is given in *Note `mysqld_safe':
  7739. mysqld_safe.
  7740.  
  7741. *Note*: The accounts that are listed in the MySQL grant tables
  7742. initially have no passwords.  After starting the server, you should set
  7743. up passwords for them using the instructions in *Note
  7744. Post-installation::.
  7745.  
  7746. MySQL Installation Using a Source Distribution
  7747. ==============================================
  7748.  
  7749. Before you proceed with the source installation, check first to see
  7750. whether our binary is available for your platform and whether it will
  7751. work for you. We put a lot of effort into making sure that our binaries
  7752. are built with the best possible options.
  7753.  
  7754. To obtain a source distribution for MySQL, *Note Getting MySQL::.
  7755.  
  7756. MySQL source distributions are provided as compressed `tar' archives
  7757. and have names of the form `mysql-VERSION.tar.gz', where VERSION is a
  7758. number like `4.0.21'.
  7759.  
  7760. You need the following tools to build and install MySQL from source:
  7761.  
  7762.    * GNU `gunzip' to uncompress the distribution.
  7763.  
  7764.    * A reasonable `tar' to unpack the distribution. GNU `tar' is known
  7765.      to work. Some operating systems come with a pre-installed version
  7766.      of `tar' that is known to have problems.  For example, Mac OS X
  7767.      `tar' and Sun `tar' are known to have problems with long
  7768.      filenames.  On Mac OS X, you can use the pre-installed `gnutar'
  7769.      program.  On other systems with a deficient `tar', you should
  7770.      install GNU `tar' first.
  7771.  
  7772.    * A working ANSI C++ compiler.  `gcc' 2.95.2 or later, `egcs' 1.0.2
  7773.      or later or `egcs 2.91.66', SGI C++, and SunPro C++ are some of the
  7774.      compilers that are known to work.  `libg++' is not needed when
  7775.      using `gcc'.  `gcc' 2.7.x has a bug that makes it impossible to
  7776.      compile some perfectly legal C++ files, such as `sql/sql_base.cc'.
  7777.      If you have only `gcc' 2.7.x, you must upgrade your `gcc' to be
  7778.      able to compile MySQL. `gcc' 2.8.1 is also known to have problems
  7779.      on some platforms, so it should be avoided if a new compiler
  7780.      exists for the platform.
  7781.  
  7782.      `gcc' 2.95.2 or later is recommended when compiling MySQL 3.23.x.
  7783.  
  7784.    * A good `make' program.  GNU `make' is always recommended and is
  7785.      sometimes required.  If you have problems, we recommend trying GNU
  7786.      `make' 3.75 or newer.
  7787.  
  7788. If you are using a version of `gcc' recent enough to understand the
  7789. `-fno-exceptions' option, it is _very important_ that you use this
  7790. option. Otherwise, you may compile a binary that crashes randomly. We
  7791. also recommend that you use `-felide-constructors' and `-fno-rtti' along
  7792. with `-fno-exceptions'. When in doubt, do the following:
  7793.  
  7794.      CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors \
  7795.             -fno-exceptions -fno-rtti" ./configure \
  7796.             --prefix=/usr/local/mysql --enable-assembler \
  7797.             --with-mysqld-ldflags=-all-static
  7798.  
  7799. On most systems, this will give you a fast and stable binary.
  7800.  
  7801. If you run into problems, _please always use `mysqlbug'_ when posting
  7802. questions to a MySQL mailing list.  Even if the problem isn't a bug,
  7803. `mysqlbug' gathers system information that will help others solve your
  7804. problem.  By not using `mysqlbug', you lessen the likelihood of getting
  7805. a solution to your problem.  You will find `mysqlbug' in the `scripts'
  7806. directory after you unpack the distribution.  *Note Bug reports::.
  7807.  
  7808. Source Installation Overview
  7809. ----------------------------
  7810.  
  7811. The basic commands you must execute to install a MySQL source
  7812. distribution are:
  7813.  
  7814.      shell> groupadd mysql
  7815.      shell> useradd -g mysql mysql
  7816.      shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -
  7817.      shell> cd mysql-VERSION
  7818.      shell> ./configure --prefix=/usr/local/mysql
  7819.      shell> make
  7820.      shell> make install
  7821.      shell> cp support-files/my-medium.cnf /etc/my.cnf
  7822.      shell> cd /usr/local/mysql
  7823.      shell> bin/mysql_install_db --user=mysql
  7824.      shell> chown -R root  .
  7825.      shell> chown -R mysql var
  7826.      shell> chgrp -R mysql .
  7827.      shell> bin/mysqld_safe --user=mysql &
  7828.  
  7829. For versions of MySQL older than 4.0, substitute `bin/safe_mysqld' for
  7830. `bin/mysqld_safe' in the final command.
  7831.  
  7832. If you start from a source RPM, do the following:
  7833.  
  7834.      shell> rpmbuild --rebuild --clean MySQL-VERSION.src.rpm
  7835.  
  7836. This will make a binary RPM that you can install. For older versions of
  7837. RPM, you may have to replace the command `rpmbuild' with `rpm' instead.
  7838.  
  7839. *Note*: This procedure does not set up any passwords for MySQL
  7840. accounts.  After following the procedure, proceed to *Note
  7841. Post-installation::, for post-installation setup and testing.
  7842.  
  7843. A more detailed version of the preceding description for installing
  7844. MySQL from a source distribution follows:
  7845.  
  7846.   1. Add a login user and group for `mysqld' to run as:
  7847.  
  7848.           shell> groupadd mysql
  7849.           shell> useradd -g mysql mysql
  7850.  
  7851.      These commands add the `mysql' group and the `mysql' user.  The
  7852.      syntax for `useradd' and `groupadd' may differ slightly on
  7853.      different versions of Unix.  They may also be called `adduser' and
  7854.      `addgroup'.
  7855.  
  7856.      You might want to call the user and group something else instead
  7857.      of `mysql'.  If so, substitute the appropriate name in the
  7858.      following steps.
  7859.  
  7860.   2. Pick the directory under which you want to unpack the
  7861.      distribution, and change location into it.
  7862.  
  7863.   3. Obtain a distribution file from one of the sites listed in *Note
  7864.      Getting MySQL: Getting MySQL.
  7865.  
  7866.   4. Unpack the distribution into the current directory:
  7867.           shell> gunzip < /PATH/TO/MYSQL-VERSION.tar.gz | tar xvf -
  7868.  
  7869.      This command creates a directory named `mysql-VERSION'.
  7870.  
  7871.      With GNU `tar', no separate invocation of `gunzip' is necessary.
  7872.      You can use the following alternative command to uncompress and
  7873.      extract the distribution:
  7874.  
  7875.           shell> tar zxvf /PATH/TO/MYSQL-VERSION-OS.tar.gz
  7876.  
  7877.   5. Change location into the top-level directory of the unpacked
  7878.      distribution:
  7879.  
  7880.           shell> cd mysql-VERSION
  7881.  
  7882.      Note that currently you must configure and build MySQL from this
  7883.      top-level directory.  You cannot build it in a different directory.
  7884.  
  7885.   6. Configure the release and compile everything:
  7886.  
  7887.           shell> ./configure --prefix=/usr/local/mysql
  7888.           shell> make
  7889.  
  7890.      When you run `configure', you might want to specify some options.
  7891.      Run `./configure --help' for a list of options.  *Note `configure'
  7892.      options: configure options, discusses some of the more useful
  7893.      options.
  7894.  
  7895.      If `configure' fails and you are going to send mail to a MySQL
  7896.      mailing list to ask for assistance, please include any lines from
  7897.      `config.log' that you think can help solve the problem.  Also
  7898.      include the last couple of lines of output from `configure'.  Post
  7899.      the bug report using the `mysqlbug' script.  *Note Bug reports::.
  7900.  
  7901.      If the compile fails, see *Note Compilation problems:: for help.
  7902.  
  7903.   7. Install the distribution:
  7904.  
  7905.           shell> make install
  7906.  
  7907.      If you want to set up an option file, use one of those present in
  7908.      the `support-files' directory as a template. For example:
  7909.  
  7910.           shell> cp support-files/my-medium.cnf /etc/my.cnf
  7911.  
  7912.      You might need to run these commands as `root'.
  7913.  
  7914.      If you want to configure support for `InnoDB' tables, you should
  7915.      edit the `/etc/my.cnf' file, remove the `#' character before the
  7916.      option lines that start with `innodb_...', and modify the option
  7917.      values to be what you want.  See *Note Option files:: and *Note
  7918.      `InnoDB' configuration: InnoDB configuration.
  7919.  
  7920.   8. Change location into the installation directory:
  7921.  
  7922.           shell> cd /usr/local/mysql
  7923.  
  7924.   9. If you haven't installed MySQL before, you must create the MySQL
  7925.      grant tables:
  7926.  
  7927.           shell> bin/mysql_install_db --user=mysql
  7928.  
  7929.      If you run the command as `root', you should use the `--user'
  7930.      option as shown.  The value of the option should be the name of
  7931.      the login account that you created in the first step to use for
  7932.      running the server.  If you run the command while logged in as
  7933.      that user, you can omit the `--user' option.
  7934.  
  7935.      Note that for MySQL versions older than 3.22.10,
  7936.      `mysql_install_db' left the server running after creating the grant
  7937.      tables.  This is no longer true; you will need to restart the
  7938.      server after performing the remaining steps in this procedure.
  7939.  
  7940.  10. Change the ownership of program binaries to `root' and ownership
  7941.      of the data directory to the user that you will run `mysqld' as.
  7942.      Assuming that you are located in the installation directory
  7943.      (`/usr/local/mysql'), the commands look like this:
  7944.  
  7945.           shell> chown -R root  .
  7946.           shell> chown -R mysql var
  7947.           shell> chgrp -R mysql .
  7948.  
  7949.      The first command changes the owner attribute of the files to the
  7950.      `root' user. The second changes the owner attribute of the data
  7951.      directory to the `mysql' user. The third changes the group
  7952.      attribute to the `mysql' group.
  7953.  
  7954.  11. If you would like MySQL to start automatically when you boot your
  7955.      machine, you can copy `support-files/mysql.server' to the location
  7956.      where your system has its startup files.  More information can be
  7957.      found in the `support-files/mysql.server' script itself and in
  7958.      *Note Automatic start::.
  7959.  
  7960.  12. You can set up new accounts using the `bin/mysql_setpermission'
  7961.      script if you install the `DBI' and `DBD::mysql' Perl modules.
  7962.      For instructions, see *Note Perl support::.
  7963.  
  7964.  
  7965. After everything has been installed, you should initialize and test your
  7966. distribution using this command:
  7967.  
  7968.      shell> /usr/local/mysql/bin/mysqld_safe --user=mysql &
  7969.  
  7970. For versions of MySQL older than 4.0, substitute `safe_mysqld' for
  7971. `mysqld_safe' in the command.
  7972.  
  7973. If that command fails immediately and prints `mysqld ended', you can
  7974. find some information in the `HOST_NAME.err' file in the data directory.
  7975.  
  7976. More information about `mysqld_safe' is given in *Note `mysqld_safe':
  7977. mysqld_safe.
  7978.  
  7979. *Note*: The accounts that are listed in the MySQL grant tables
  7980. initially have no passwords.  After starting the server, you should set
  7981. up passwords for them using the instructions in *Note
  7982. Post-installation::.
  7983.  
  7984. Typical `configure' Options
  7985. ---------------------------
  7986.  
  7987. The `configure' script gives you a great deal of control over how you
  7988. configure a MySQL source distribution.  Typically you do this using
  7989. options on the `configure' command line.  You can also affect
  7990. `configure' using certain environment variables.  *Note Environment
  7991. variables::.  For a list of options supported by `configure', run this
  7992. command:
  7993.  
  7994.      shell> ./configure --help
  7995.  
  7996. Some of the more commonly used `configure' options are described here:
  7997.  
  7998.    * To compile just the MySQL client libraries and client programs and
  7999.      not the server, use the `--without-server' option:
  8000.  
  8001.           shell> ./configure --without-server
  8002.  
  8003.      If you don't have a C++ compiler, `mysql' will not compile (it is
  8004.      the one client program that requires C++).  In this case, you can
  8005.      remove the code in `configure' that tests for the C++ compiler and
  8006.      then run `./configure' with the `--without-server' option. The
  8007.      compile step will still try to build `mysql', but you can ignore
  8008.      any warnings about `mysql.cc'.  (If `make' stops, try `make -k' to
  8009.      tell it to continue with the rest of the build even if errors
  8010.      occur.)
  8011.  
  8012.    * If you want to build the embedded MySQL library (`libmysqld.a')
  8013.      you should use the `--with-embedded-server' option.
  8014.  
  8015.    * If you don't want your log files and database directories located
  8016.      under `/usr/local/var', use a `configure' command something like
  8017.      one of these:
  8018.  
  8019.           shell> ./configure --prefix=/usr/local/mysql
  8020.           shell> ./configure --prefix=/usr/local \
  8021.                      --localstatedir=/usr/local/mysql/data
  8022.  
  8023.      The first command changes the installation prefix so that
  8024.      everything is installed under `/usr/local/mysql' rather than the
  8025.      default of `/usr/local'.  The second command preserves the default
  8026.      installation prefix, but overrides the default location for
  8027.      database directories (normally `/usr/local/var') and changes it to
  8028.      `/usr/local/mysql/data'.  After you have compiled MySQL, you can
  8029.      change these options with option files. *Note Option files::.
  8030.  
  8031.    * If you are using Unix and you want the MySQL socket located
  8032.      somewhere other than the default location (normally in the
  8033.      directory `/tmp' or `/var/run'), use a `configure' command like
  8034.      this:
  8035.  
  8036.           shell> ./configure \
  8037.                      --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
  8038.  
  8039.      The socket filename must be an absolute pathname.  You can also
  8040.      change the location of `mysql.sock' later by using a MySQL option
  8041.      file. *Note Problems with `mysql.sock': Problems with mysql.sock.
  8042.  
  8043.    * If you want to compile statically linked programs (for example, to
  8044.      make a binary distribution, to get more speed, or to work around
  8045.      problems with some Red Hat Linux distributions), run `configure'
  8046.      like this:
  8047.  
  8048.           shell> ./configure --with-client-ldflags=-all-static \
  8049.                      --with-mysqld-ldflags=-all-static
  8050.  
  8051.    * If you are using `gcc' and don't have `libg++' or `libstdc++'
  8052.      installed, you can tell `configure' to use `gcc' as your C++
  8053.      compiler:
  8054.  
  8055.           shell> CC=gcc CXX=gcc ./configure
  8056.  
  8057.      When you use `gcc' as your C++ compiler, it will not attempt to
  8058.      link in `libg++' or `libstdc++'.  This may be a good idea to do
  8059.      even if you have these libraries installed, because some versions
  8060.      of them have caused strange problems for MySQL users in the past.
  8061.  
  8062.      The following list indicates some compilers and environment
  8063.      variable settings that are commonly used with each one.
  8064.  
  8065.     `gcc' 2.7.2:
  8066.                CC=gcc CXX=gcc CXXFLAGS="-O3 -felide-constructors"
  8067.  
  8068.     `egcs' 1.0.3a:
  8069.                CC=gcc CXX=gcc CXXFLAGS="-O3 -felide-constructors \
  8070.                -fno-exceptions -fno-rtti"
  8071.  
  8072.     `gcc' 2.95.2:
  8073.                CFLAGS="-O3 -mpentiumpro" CXX=gcc CXXFLAGS="-O3 -mpentiumpro \
  8074.                -felide-constructors -fno-exceptions -fno-rtti"
  8075.  
  8076.     `pgcc' 2.90.29 or newer:
  8077.                CFLAGS="-O3 -mpentiumpro -mstack-align-double" CXX=gcc \
  8078.                CXXFLAGS="-O3 -mpentiumpro -mstack-align-double \
  8079.                -felide-constructors -fno-exceptions -fno-rtti"
  8080.  
  8081.      In most cases, you can get a reasonably optimized MySQL binary by
  8082.      using the options from the preceding list and adding the following
  8083.      options to the `configure' line:
  8084.  
  8085.           --prefix=/usr/local/mysql --enable-assembler \
  8086.           --with-mysqld-ldflags=-all-static
  8087.  
  8088.      The full `configure' line would, in other words, be something like
  8089.      the following for all recent `gcc' versions:
  8090.  
  8091.           CFLAGS="-O3 -mpentiumpro" CXX=gcc CXXFLAGS="-O3 -mpentiumpro \
  8092.           -felide-constructors -fno-exceptions -fno-rtti" ./configure \
  8093.           --prefix=/usr/local/mysql --enable-assembler \
  8094.           --with-mysqld-ldflags=-all-static
  8095.  
  8096.      The binaries we provide on the MySQL Web site at
  8097.      `http://www.mysql.com/' are all compiled with full optimization and
  8098.      should be perfect for most users.  *Note MySQL binaries::.  There
  8099.      are some configuration settings you can tweak to make an even
  8100.      faster binary, but these are only for advanced users.  *Note
  8101.      Compile and link options::.
  8102.  
  8103.      If the build fails and produces errors about your compiler or
  8104.      linker not being able to create the shared library
  8105.      `libmysqlclient.so.#' (where `#' is a version number), you can
  8106.      work around this problem by giving the `--disable-shared' option
  8107.      to `configure'.  In this case, `configure' will not build a shared
  8108.      `libmysqlclient.so.#' library.
  8109.  
  8110.    * You can configure MySQL not to use `DEFAULT' column values for
  8111.      non-`NULL' columns (that is, columns that are not allowed to be
  8112.      `NULL'). *Note constraint NOT NULL::.
  8113.  
  8114.           shell> CXXFLAGS=-DDONT_USE_DEFAULT_FIELDS ./configure
  8115.  
  8116.      The effect of this flag is to cause any `INSERT' statement to fail
  8117.      unless it includes explicit values for all columns that require a
  8118.      non-`NULL' value.
  8119.  
  8120.    * By default, MySQL uses the `latin1' (ISO-8859-1) character set. To
  8121.      change the default set, use the `--with-charset' option:
  8122.           shell> ./configure --with-charset=CHARSET
  8123.      CHARSET may be one of `big5', `cp1251', `cp1257', `czech',
  8124.      `danish', `dec8', `dos', `euc_kr', `gb2312', `gbk', `german1',
  8125.      `hebrew', `hp8', `hungarian', `koi8_ru', `koi8_ukr', `latin1',
  8126.      `latin2', `sjis', `swe7', `tis620', `ujis', `usa7', or
  8127.      `win1251ukr'.  *Note Character sets::.
  8128.  
  8129.      As of MySQL 4.1.1, the default collation may also be specified.
  8130.      MySQL uses the `latin1_swedish_ci' collation. To change this, use
  8131.      the `--with-collation' option:
  8132.  
  8133.           shell> ./configure --with-collation=COLLATION
  8134.  
  8135.      To change both the character set and the collation, use both the
  8136.      `--with-charset' and `--with-collation' options.  The collation
  8137.      must be a legal collation for the character set.  (Use the `SHOW
  8138.      COLLATION' statement to determine which collations are available
  8139.      for each character set.)
  8140.  
  8141.      If you want to convert characters between the server and the
  8142.      client, you should take a look at the `SET CHARACTER SET'
  8143.      statement.  *Note `SET': SET OPTION.
  8144.  
  8145.      *Warning:* If you change character sets after having created any
  8146.      tables, you will have to run `myisamchk -r -q
  8147.      --set-character-set=CHARSET' on every table. Your indexes may be
  8148.      sorted incorrectly otherwise.  (This can happen if you install
  8149.      MySQL, create some tables, then reconfigure MySQL to use a
  8150.      different character set and reinstall it.)
  8151.  
  8152.      With the `configure' option `--with-extra-charsets=LIST', you can
  8153.      define which additional character sets should be compiled into the
  8154.      server.  LIST is either a list of character set names separated by
  8155.      spaces, `complex' to include all character sets that can't be
  8156.      dynamically loaded, or `all' to include all character sets into
  8157.      the binaries.
  8158.  
  8159.    * To configure MySQL with debugging code, use the `--with-debug'
  8160.      option:
  8161.           shell> ./configure --with-debug
  8162.      This causes a safe memory allocator to be included that can find
  8163.      some errors and that provides output about what is happening.
  8164.      *Note Debugging server::.
  8165.  
  8166.    * If your client programs are using threads, you also must compile a
  8167.      thread-safe version of the MySQL client library with the
  8168.      `--enable-thread-safe-client' configure option. This will create a
  8169.      `libmysqlclient_r' library with which you should link your threaded
  8170.      applications.  *Note Threaded clients::.
  8171.  
  8172.    * Options that pertain to particular systems can be found in the
  8173.      system-specific section of this manual.  *Note Operating System
  8174.      Specific Notes::.
  8175.  
  8176. Installing from the Development Source Tree
  8177. -------------------------------------------
  8178.  
  8179. *Caution*: You should read this section only if you are interested in
  8180. helping us test our new code. If you just want to get MySQL up and
  8181. running on your system, you should use a standard release distribution
  8182. (either a binary or source distribution will do).
  8183.  
  8184. To obtain our most recent development source tree, use these
  8185. instructions:
  8186.  
  8187.   1. Download BitKeeper from
  8188.      `http://www.bitmover.com/cgi-bin/download.cgi'.  You will need
  8189.      Bitkeeper 3.0 or newer to access our repository.
  8190.  
  8191.   2. Follow the instructions to install it.
  8192.  
  8193.   3. After BitKeeper has been installed, first go to the directory you
  8194.      want to work from, and then use one of the following commands to
  8195.      clone the MySQL version branch of your choice:
  8196.  
  8197.      To clone the old 3.23 branch, use this command:
  8198.  
  8199.           shell> bk clone bk://mysql.bkbits.net/mysql-3.23 mysql-3.23
  8200.  
  8201.      To clone the 4.0 stable (production) branch, use this command:
  8202.  
  8203.           shell> bk clone bk://mysql.bkbits.net/mysql-4.0 mysql-4.0
  8204.  
  8205.      To clone the 4.1 beta branch, use this command:
  8206.  
  8207.           shell> bk clone bk://mysql.bkbits.net/mysql-4.1 mysql-4.1
  8208.  
  8209.      To clone the 5.0 development branch, use this command:
  8210.  
  8211.           shell> bk clone bk://mysql.bkbits.net/mysql-5.0 mysql-5.0
  8212.  
  8213.      In the preceding examples, the source tree will be set up in the
  8214.      `mysql-3.23/', `mysql-4.0/', `mysql-4.1/', or `mysql-5.0/'
  8215.      subdirectory of your current directory.
  8216.  
  8217.      If you are behind a firewall and can only initiate HTTP
  8218.      connections, you can also use BitKeeper via HTTP.
  8219.  
  8220.      If you are required to use a proxy server, set the environment
  8221.      variable `http_proxy' to point to your proxy:
  8222.  
  8223.           shell> export http_proxy="http://your.proxy.server:8080/"
  8224.  
  8225.      Now, simply replace the `bk://' with `http://' when doing a clone.
  8226.      Example:
  8227.  
  8228.           shell> bk clone http://mysql.bkbits.net/mysql-4.1 mysql-4.1
  8229.  
  8230.      The initial download of the source tree may take a while,
  8231.      depending on the speed of your connection. Please be patient.
  8232.  
  8233.   4. You will need GNU `make', `autoconf' 2.53 (or newer), `automake'
  8234.      1.5, `libtool' 1.5, and `m4' to run the next set of commands. Even
  8235.      though many operating systems already come with their own
  8236.      implementation of `make', chances are high that the compilation
  8237.      will fail with strange error messages. Therefore, it is highly
  8238.      recommended that you use GNU `make' (sometimes named `gmake')
  8239.      instead.
  8240.  
  8241.      Fortunately, a large number of operating systems already ship with
  8242.      the GNU toolchain preinstalled or supply installable packages of
  8243.      these. In any case, they can also be downloaded from the following
  8244.      locations:
  8245.  
  8246.         * `http://www.gnu.org/software/autoconf/'
  8247.  
  8248.         * `http://www.gnu.org/software/automake/'
  8249.  
  8250.         * `http://www.gnu.org/software/libtool/'
  8251.  
  8252.         * `http://www.gnu.org/software/m4/'
  8253.  
  8254.         * `http://www.gnu.org/software/make/'
  8255.  
  8256.      If you are trying to configure MySQL 4.1 or later, you will also
  8257.      need GNU `bison' 1.75 or later.  Older versions of `bison' may
  8258.      report this error:
  8259.  
  8260.           sql_yacc.yy:#####: fatal error: maximum table size (32767) exceeded
  8261.  
  8262.      Note: The maximum table size is not actually exceeded; the error
  8263.      is caused by bugs in older versions of `bison'.
  8264.  
  8265.      Versions of MySQL before version 4.1 may also compile with other
  8266.      `yacc' implementations (for example, BSD `yacc' 91.7.30). For later
  8267.      versions, GNU `bison' is required.
  8268.  
  8269.      The following example shows the typical commands required to
  8270.      configure a source tree. The first `cd' command changes location
  8271.      into the top-level directory of the tree; replace `mysql-4.0' with
  8272.      the appropriate directory name.
  8273.  
  8274.           shell> cd mysql-4.0
  8275.           shell> bk -r edit
  8276.           shell> aclocal; autoheader; autoconf; automake
  8277.           shell> (cd innobase; aclocal; autoheader; autoconf; automake)
  8278.           shell> (cd bdb/dist; sh s_all)
  8279.           shell> ./configure  # Add your favorite options here
  8280.           make
  8281.  
  8282.      The command lines that change directory into the `innobase' and
  8283.      `bdb/dist' directories are used to configure the `InnoDB' and
  8284.      Berkeley DB (`BDB') storage engines.  You can omit these command
  8285.      lines if you to not require `InnoDB' or `BDB' support.
  8286.  
  8287.      If you get some strange errors during this stage, verify that you
  8288.      really have `libtool' installed.
  8289.  
  8290.      A collection of our standard configuration scripts is located in
  8291.      the `BUILD/' subdirectory.  You may find it more convenient to use
  8292.      the `BUILD/compile-pentium-debug' script than the preceding set of
  8293.      shell commands. To compile on a different architecture, modify the
  8294.      script by removing flags that are Pentium-specific.
  8295.  
  8296.   5. When the build is done, run `make install'.  Be careful with this
  8297.      on a production machine; the command may overwrite your live
  8298.      release installation.  If you have another installation of MySQL,
  8299.      we recommend that you run `./configure' with different values for
  8300.      the `--prefix', `--with-tcp-port', and `--unix-socket-path' options
  8301.      than those used for your production server.
  8302.  
  8303.   6. Play hard with your new installation and try to make the new
  8304.      features crash.  Start by running `make test'.  *Note MySQL test
  8305.      suite::.
  8306.  
  8307.   7. If you have gotten to the `make' stage and the distribution does
  8308.      not compile, please report it in our bugs database at
  8309.      `http://bugs.mysql.com/'.  If you have installed the latest
  8310.      versions of the required GNU tools, and they crash trying to
  8311.      process our configuration files, please report that also.
  8312.      However, if you execute `aclocal' and get a `command not found'
  8313.      error or a similar problem, do not report it.  Instead, make sure
  8314.      that all the necessary tools are installed and that your `PATH'
  8315.      variable is set correctly so that your shell can find them.
  8316.  
  8317.   8. After the initial `bk clone' operation to obtain the source tree,
  8318.      you should run `bk pull' periodically to get updates.
  8319.  
  8320.   9. You can examine the change history for the tree with all the diffs
  8321.      by using `bk revtool'.  If you see some funny diffs or code that
  8322.      you have a question about, do not hesitate to send email to the
  8323.      MySQL `internals' mailing list.  *Note Mailing-list::.  Also, if
  8324.      you think you have a better idea on how to do something, send an
  8325.      email message to the same address with a patch.  `bk diffs' will
  8326.      produce a patch for you after you have made changes to the source.
  8327.      If you do not have the time to code your idea, just send a
  8328.      description.
  8329.  
  8330.  10. BitKeeper has a nice help utility that you can access via `bk
  8331.      helptool'.
  8332.  
  8333.  11. Please note that any commits (made via `bk ci' or `bk citool') will
  8334.      trigger the posting of a message with the changeset to our
  8335.      internals mailing list, as well as the usual openlogging.org
  8336.      submission with just the changeset comments.  Generally, you
  8337.      wouldn't need to use commit (since the public tree will not allow
  8338.      `bk push'), but rather use the `bk diffs' method described
  8339.      previously.
  8340.  
  8341.  
  8342. You can also browse changesets, comments, and source code online. For
  8343. example, to browse this information for MySQL 4.1, go to
  8344. `http://mysql.bkbits.net:8080/mysql-4.1'.
  8345.  
  8346. The manual is in a separate tree that can be cloned with:
  8347.  
  8348.      shell> bk clone bk://mysql.bkbits.net/mysqldoc mysqldoc
  8349.  
  8350. There are also public BitKeeper trees for MySQL Control Center and
  8351. Connector/ODBC. They can be cloned respectively as follows.
  8352.  
  8353. To clone MySQL Control center, use this command:
  8354.  
  8355.      shell> bk clone http://mysql.bkbits.net/mysqlcc mysqlcc
  8356.  
  8357. To clone Connector/ODBC, use this command:
  8358.  
  8359.      shell> bk clone http://mysql.bkbits.net/myodbc3 myodbc3
  8360.  
  8361. Dealing with Problems Compiling MySQL
  8362. -------------------------------------
  8363.  
  8364. All MySQL programs compile cleanly for us with no warnings on Solaris
  8365. or Linux using `gcc'.  On other systems, warnings may occur due to
  8366. differences in system include files.  See *Note MIT-pthreads:: for
  8367. warnings that may occur when using MIT-pthreads.  For other problems,
  8368. check the following list.
  8369.  
  8370. The solution to many problems involves reconfiguring.  If you do need to
  8371. reconfigure, take note of the following:
  8372.  
  8373.    * If `configure' is run after it already has been run, it may use
  8374.      information that was gathered during its previous invocation.  This
  8375.      information is stored in `config.cache'.  When `configure' starts
  8376.      up, it looks for that file and reads its contents if it exists, on
  8377.      the assumption that the information is still correct.  That
  8378.      assumption is invalid when you reconfigure.
  8379.  
  8380.    * Each time you run `configure', you must run `make' again to
  8381.      recompile.  However, you may want to remove old object files from
  8382.      previous builds first because they were compiled using different
  8383.      configuration options.
  8384.  
  8385. To prevent old configuration information or object files from being
  8386. used, run these commands before re-running `configure':
  8387.  
  8388.      shell> rm config.cache
  8389.      shell> make clean
  8390.  
  8391. Alternatively, you can run `make distclean'.
  8392.  
  8393. The following list describes some of the problems when compiling MySQL
  8394. that have been found to occur most often:
  8395.  
  8396.    * If you get errors such as the ones shown here when compiling
  8397.      `sql_yacc.cc', you probably have run out of memory or swap space:
  8398.  
  8399.           Internal compiler error: program cc1plus got fatal signal 11
  8400.           Out of virtual memory
  8401.           Virtual memory exhausted
  8402.  
  8403.      The problem is that `gcc' requires a huge amount of memory to
  8404.      compile `sql_yacc.cc' with inline functions.  Try running
  8405.      `configure' with the `--with-low-memory' option:
  8406.  
  8407.           shell> ./configure --with-low-memory
  8408.  
  8409.      This option causes `-fno-inline' to be added to the compile line
  8410.      if you are using `gcc' and `-O0' if you are using something else.
  8411.      You should try the `--with-low-memory' option even if you have so
  8412.      much memory and swap space that you think you can't possibly have
  8413.      run out.  This problem has been observed to occur even on systems
  8414.      with generous hardware configurations and the `--with-low-memory'
  8415.      option usually fixes it.
  8416.  
  8417.    * By default, `configure' picks `c++' as the compiler name and GNU
  8418.      `c++' links with `-lg++'.  If you are using `gcc', that behavior
  8419.      can cause problems during configuration such as this:
  8420.  
  8421.           configure: error: installation or configuration problem:
  8422.           C++ compiler cannot create executables.
  8423.  
  8424.      You might also observe problems during compilation related to
  8425.      `g++', `libg++', or `libstdc++'.
  8426.  
  8427.      One cause of these problems is that you may not have `g++', or you
  8428.      may have `g++' but not `libg++', or `libstdc++'.  Take a look at
  8429.      the `config.log' file.  It should contain the exact reason why
  8430.      your C++ compiler didn't work.  To work around these problems, you
  8431.      can use `gcc' as your C++ compiler.  Try setting the environment
  8432.      variable `CXX' to `"gcc -O3"'.  For example:
  8433.  
  8434.           shell> CXX="gcc -O3" ./configure
  8435.  
  8436.      This works because `gcc' compiles C++ sources as well as `g++'
  8437.      does, but does not link in `libg++' or `libstdc++' by default.
  8438.  
  8439.      Another way to fix these problems is to install `g++', `libg++',
  8440.      and `libstdc++'.  We would, however, like to recommend that you
  8441.      not use `libg++' or `libstdc++' with MySQL because this will only
  8442.      increase the binary size of `mysqld' without giving you any
  8443.      benefits.  Some versions of these libraries have also caused
  8444.      strange problems for MySQL users in the past.
  8445.  
  8446.      Using `gcc' as the C++ compiler is also required if you want to
  8447.      compile MySQL with RAID functionality (see *Note CREATE TABLE::
  8448.      for more info on RAID table type) and you are using GNU `gcc'
  8449.      version 3 and above. If you get errors like those following during
  8450.      the linking stage when you configure MySQL to compile with the
  8451.      option `--with-raid', try to use `gcc' as your C++ compiler by
  8452.      defining the `CXX' environment variable:
  8453.  
  8454.           gcc -O3 -DDBUG_OFF -rdynamic -o isamchk isamchk.o sort.o  libnisam.a
  8455.           ../mysys/libmysys.a ../dbug/libdbug.a ../strings/libmystrings.a
  8456.            -lpthread -lz -lcrypt -lnsl -lm -lpthread
  8457.           ../mysys/libmysys.a(raid.o)(.text+0x79): In function
  8458.           `my_raid_create':: undefined reference to `operator new(unsigned)'
  8459.           ../mysys/libmysys.a(raid.o)(.text+0xdd): In function
  8460.           `my_raid_create':: undefined reference to `operator delete(void*)'
  8461.           ../mysys/libmysys.a(raid.o)(.text+0x129): In function
  8462.           `my_raid_open':: undefined reference to `operator new(unsigned)'
  8463.           ../mysys/libmysys.a(raid.o)(.text+0x189): In function
  8464.           `my_raid_open':: undefined reference to `operator delete(void*)'
  8465.           ../mysys/libmysys.a(raid.o)(.text+0x64b): In function
  8466.           `my_raid_close':: undefined reference to `operator delete(void*)'
  8467.           collect2: ld returned 1 exit status
  8468.  
  8469.    * If your compile fails with errors such as any of the following,
  8470.      you must upgrade your version of `make' to GNU `make':
  8471.  
  8472.           making all in mit-pthreads
  8473.           make: Fatal error in reader: Makefile, line 18:
  8474.           Badly formed macro assignment
  8475.      Or:
  8476.           make: file `Makefile' line 18: Must be a separator (:
  8477.      Or:
  8478.           pthread.h: No such file or directory
  8479.  
  8480.      Solaris and FreeBSD are known to have troublesome `make' programs.
  8481.  
  8482.      GNU `make' Version 3.75 is known to work.
  8483.  
  8484.    * If you want to define flags to be used by your C or C++ compilers,
  8485.      do so by adding the flags to the `CFLAGS' and `CXXFLAGS'
  8486.      environment variables.  You can also specify the compiler names
  8487.      this way using `CC' and `CXX'.  For example:
  8488.  
  8489.           shell> CC=gcc
  8490.           shell> CFLAGS=-O3
  8491.           shell> CXX=gcc
  8492.           shell> CXXFLAGS=-O3
  8493.           shell> export CC CFLAGS CXX CXXFLAGS
  8494.  
  8495.      See *Note MySQL binaries::, for a list of flag definitions that
  8496.      have been found to be useful on various systems.
  8497.  
  8498.    * If you get an error message like this, you need to upgrade your
  8499.      `gcc' compiler:
  8500.  
  8501.           client/libmysql.c:273: parse error before `__attribute__'
  8502.  
  8503.      `gcc' 2.8.1 is known to work, but we recommend using `gcc' 2.95.2
  8504.      or `egcs' 1.0.3a instead.
  8505.  
  8506.    * If you get errors such as those shown here when compiling `mysqld',
  8507.      `configure' didn't correctly detect the type of the last argument
  8508.      to `accept()', `getsockname()', or `getpeername()':
  8509.  
  8510.           cxx: Error: mysqld.cc, line 645: In this statement, the referenced
  8511.                type of the pointer value ''length'' is ''unsigned long'',
  8512.                which is not compatible with ''int''.
  8513.           new_sock = accept(sock, (struct sockaddr *)&cAddr, &length);
  8514.  
  8515.      To fix this, edit the `config.h' file (which is generated by
  8516.      `configure').  Look for these lines:
  8517.  
  8518.           /* Define as the base type of the last arg to accept */
  8519.           #define SOCKET_SIZE_TYPE XXX
  8520.  
  8521.      Change `XXX' to `size_t' or `int', depending on your operating
  8522.      system.  (Note that you will have to do this each time you run
  8523.      `configure' because `configure' regenerates `config.h'.)
  8524.  
  8525.    * The `sql_yacc.cc' file is generated from `sql_yacc.yy'.  Normally
  8526.      the build process doesn't need to create `sql_yacc.cc', because
  8527.      MySQL comes with an already generated copy.  However, if you do
  8528.      need to re-create it, you might encounter this error:
  8529.  
  8530.           "sql_yacc.yy", line XXX fatal: default action causes potential...
  8531.  
  8532.      This is a sign that your version of `yacc' is deficient.  You
  8533.      probably need to install `bison' (the GNU version of `yacc') and
  8534.      use that instead.
  8535.  
  8536.    * On Debian Linux 3.0, you need to install `gawk' instead of the
  8537.      default `mawk' if you want to compile MySQL 4.1 or higher with
  8538.      Berkeley DB support.
  8539.  
  8540.    * If you need to debug `mysqld' or a MySQL client, run `configure'
  8541.      with the `--with-debug' option, then recompile and link your
  8542.      clients with the new client library.  *Note Debugging client::.
  8543.  
  8544.    * If you get a compilation error on Linux (for example, SuSE Linux
  8545.      8.1 or Red Hat Linux 7.3) similar to the following one:
  8546.  
  8547.           libmysql.c:1329: warning: passing arg 5 of `gethostbyname_r' from
  8548.           incompatible pointer type
  8549.           libmysql.c:1329: too few arguments to function `gethostbyname_r'
  8550.           libmysql.c:1329: warning: assignment makes pointer from integer
  8551.           without a cast
  8552.           make[2]: *** [libmysql.lo] Error 1
  8553.  
  8554.      By default, the `configure' script attempts to determine the
  8555.      correct number of arguments by using `g++' the GNU C++ compiler.
  8556.      This test yields wrong results if `g++' is not installed. There
  8557.      are two ways to work around this problem:
  8558.  
  8559.         * Make sure that the GNU C++ `g++' is installed. On some Linux
  8560.           distributions, the required package is called `gpp'; on
  8561.           others, it is named `gcc-c++'.
  8562.  
  8563.         * Use `gcc' as your C++ compiler by setting the `CXX'
  8564.           environment variable to `gcc':
  8565.                export CXX="gcc"
  8566.  
  8567.      Please note that you need to run `configure' again afterward.
  8568.  
  8569.  
  8570. MIT-pthreads Notes
  8571. ------------------
  8572.  
  8573. This section describes some of the issues involved in using
  8574. MIT-pthreads.
  8575.  
  8576. On Linux, you should _not_ use MIT-pthreads. Use the installed
  8577. LinuxThreads implementation instead.  *Note Linux::.
  8578.  
  8579. If your system does not provide native thread support, you will need to
  8580. build MySQL using the MIT-pthreads package.  This includes older
  8581. FreeBSD systems, SunOS 4.x, Solaris 2.4 and earlier, and some others.
  8582. *Note Which OS::.
  8583.  
  8584. Beginning with MySQL 4.0.2, MIT-pthreads is no longer part of the
  8585. source distribution. If you require this package, you need to download
  8586. it separately from
  8587. `http://www.mysql.com/Downloads/Contrib/pthreads-1_60_beta6-mysql.tar.gz'
  8588.  
  8589. After downloading, extract this source archive into the top level of the
  8590. MySQL source directory. It will create a new subdirectory named
  8591. `mit-pthreads'.
  8592.  
  8593.    * On most systems, you can force MIT-pthreads to be used by running
  8594.      `configure' with the `--with-mit-threads' option:
  8595.  
  8596.           shell> ./configure --with-mit-threads
  8597.  
  8598.      Building in a non-source directory is not supported when using
  8599.      MIT-pthreads because we want to minimize our changes to this code.
  8600.  
  8601.    * The checks that determine whether to use MIT-pthreads occur only
  8602.      during the part of the configuration process that deals with the
  8603.      server code.  If you have configured the distribution using
  8604.      `--without-server' to build only the client code, clients will not
  8605.      know whether MIT-pthreads is being used and will use Unix socket
  8606.      connections by default.  Because Unix socket files do not work
  8607.      under MIT-pthreads on some platforms, this means you will need to
  8608.      use `-h' or `--host' when you run client programs.
  8609.  
  8610.    * When MySQL is compiled using MIT-pthreads, system locking is
  8611.      disabled by default for performance reasons.  You can tell the
  8612.      server to use system locking with the `--external-locking' option.
  8613.      This is needed only if you want to be able to run two MySQL
  8614.      servers against the same data files, which is not recommended.
  8615.  
  8616.    * Sometimes the pthread `bind()' command fails to bind to a socket
  8617.      without any error message (at least on Solaris).  The result is
  8618.      that all connections to the server fail.  For example:
  8619.  
  8620.           shell> mysqladmin version
  8621.           mysqladmin: connect to server at '' failed;
  8622.           error: 'Can't connect to mysql server on localhost (146)'
  8623.  
  8624.      The solution to this is to kill the `mysqld' server and restart it.
  8625.      This has only happened to us when we have forced down the server
  8626.      and done a restart immediately.
  8627.  
  8628.    * With MIT-pthreads, the `sleep()' system call isn't interruptible
  8629.      with `SIGINT' (break).  This is only noticeable when you run
  8630.      `mysqladmin --sleep'.  You must wait for the `sleep()' call to
  8631.      terminate before the interrupt is served and the process stops.
  8632.  
  8633.    * When linking, you may receive warning messages like these (at
  8634.      least on Solaris); they can be ignored:
  8635.  
  8636.           ld: warning: symbol `_iob' has differing sizes:
  8637.               (file /my/local/pthreads/lib/libpthread.a(findfp.o) value=0x4;
  8638.           file /usr/lib/libc.so value=0x140);
  8639.               /my/local/pthreads/lib/libpthread.a(findfp.o) definition taken
  8640.           ld: warning: symbol `__iob' has differing sizes:
  8641.               (file /my/local/pthreads/lib/libpthread.a(findfp.o) value=0x4;
  8642.           file /usr/lib/libc.so value=0x140);
  8643.               /my/local/pthreads/lib/libpthread.a(findfp.o) definition taken
  8644.  
  8645.    * Some other warnings also can be ignored:
  8646.  
  8647.           implicit declaration of function `int strtoll(...)'
  8648.           implicit declaration of function `int strtoul(...)'
  8649.  
  8650.    * We haven't gotten `readline' to work with MIT-pthreads.  (This
  8651.      isn't needed, but may be interesting for someone.)
  8652.  
  8653. Installing MySQL from Source on Windows
  8654. ---------------------------------------
  8655.  
  8656. These instructions describe how to build MySQL binaries from source for
  8657. versions 4.1 and above on Windows. Instructions are provided for
  8658. building binaries from a standard source distribution or from the
  8659. BitKeeper tree that contains the latest development source.
  8660.  
  8661. *Note*: The instructions in this document are strictly for users who
  8662. want to test MySQL on Windows from the latest source distribution or
  8663. from the BitKeeper tree.  For production use, MySQL AB does not advise
  8664. using a MySQL server built by yourself from source.  Normally, it is
  8665. best to use precompiled binary distributions of MySQL that are built
  8666. specifically for optimal performance on Windows by MySQL AB.
  8667. Instructions for installing a binary distributions are available at
  8668. *Note Windows installation::.
  8669.  
  8670. To build MySQL on Windows from source, you need the following compiler
  8671. and resources available on your Windows system:
  8672.  
  8673.    * VC++ 6.0 compiler (updated with 4 or 5 SP and pre-processor
  8674.      package).  The pre-processor package is necessary for the macro
  8675.      assembler.  More details can be found at
  8676.      `http://msdn.microsoft.com/vstudio/downloads/updates/sp/vs6/sp5/faq.aspx'.
  8677.  
  8678.    * Approximately 45MB disk space.
  8679.  
  8680.    * 64MB RAM.
  8681.  
  8682.  
  8683. You'll also need a MySQL source distribution for Windows.  There are
  8684. two ways you can get a source distribution for MySQL version 4.1 and
  8685. above:
  8686.  
  8687.   1. Obtain a source distribution packaged by MySQL AB for the
  8688.      particular version of MySQL in which you are interested.
  8689.      Prepackaged source distributions are available for released
  8690.      versions of MySQL and can be obtained from
  8691.      `http://dev.mysql.com/downloads/'.
  8692.  
  8693.   2. You can package a source distribution yourself from the latest
  8694.      BitKeeper developer source tree. If you plan to do this, you must
  8695.      create the package on a Unix system and then transfer it to your
  8696.      Windows system.  (The reason for this is that some of the
  8697.      configuration and build steps require tools that work only on
  8698.      Unix.)  The BitKeeper approach thus requires:
  8699.  
  8700.         * A system running Unix, or a Unix-like system such as Linux.
  8701.  
  8702.         * BitKeeper 3.0 installed on that system. You can obtain
  8703.           BitKeeper from `http://www.bitkeeper.com/'.
  8704.  
  8705.  
  8706.  
  8707. If you are using a Windows source distribution, you can go directly to
  8708. *Note Windows VC++ Build::. To build from the BitKeeper tree, proceed to
  8709. *Note Windows BitKeeper Build::.
  8710.  
  8711. If you find something not working as expected, or you have suggestions
  8712. about ways to improve the current build process on Windows, please send
  8713. a message to the `win32' mailing list.  *Note Mailing-list::.
  8714.  
  8715. Building MySQL Using VC++
  8716. .........................
  8717.  
  8718. *Note*: VC++ workspace files for MySQL 4.1 and above are compatible with
  8719. Microsoft Visual Studio 6.0 and above (7.0/.NET) editions and tested by
  8720. MySQL AB staff before each release.
  8721.  
  8722. Follow this procedure to build MySQL:
  8723.  
  8724.   1. Create a work directory (for example, `C:\workdir').
  8725.  
  8726.   2. Unpack the source distribution in the aforementioned directory
  8727.      using `WinZip' or other Windows tool that can read `.zip' files.
  8728.  
  8729.   3. Start the VC++ 6.0 compiler.
  8730.  
  8731.   4. In the `File' menu, select `Open Workspace'.
  8732.  
  8733.   5. Open the `mysql.dsw' workspace you find in the work directory.
  8734.  
  8735.   6. From the `Build' menu, select the `Set Active Configuration' menu.
  8736.  
  8737.   7. Click over the screen selecting `mysqld - Win32 Debug' and click
  8738.      OK.
  8739.  
  8740.   8. Press `F7' to begin the build of the debug server, libraries, and
  8741.      some client applications.
  8742.  
  8743.   9. Compile the release versions that you want in the same way.
  8744.  
  8745.  10. Debug versions of the programs and libraries are placed in the
  8746.      `client_debug' and `lib_debug' directories.  Release versions of
  8747.      the programs and libraries are placed in the `client_release' and
  8748.      `lib_release' directories.  Note that if you want to build both
  8749.      debug and release versions, you can select the `Build All' option
  8750.      from the `Build' menu.
  8751.  
  8752.  11. Test the server.  The server built using the preceding instructions
  8753.      will expect that the MySQL base directory and data directory are
  8754.      `C:\mysql' and `C:\mysql\data' by default. If you want to test
  8755.      your server using the source tree root directory and its data
  8756.      directory as the base directory and data directory, you will need
  8757.      to tell the server their pathnames. You can either do this on the
  8758.      command line with the `--basedir' and `--datadir' options, or
  8759.      place appropriate options in an option file (the `my.ini' file in
  8760.      your Windows directory or `C:\my.cnf').  If you have an existing
  8761.      data directory elsewhere that you want to use, you can specify its
  8762.      pathname instead.
  8763.  
  8764.  12. Start your server from the `client_release' or `client_debug'
  8765.      directory, depending on which server you want to use. The general
  8766.      server startup instructions are at *Note Windows installation::.
  8767.      You'll need to adapt the instructions appropriately if you want to
  8768.      use a different base directory or data directory.
  8769.  
  8770.  13. When the server is running in standalone fashion or as a service
  8771.      based on your configuration, try to connect to it from the `mysql'
  8772.      interactive command-line utility that exists in your
  8773.      `client_release' or `client_debug' directory.
  8774.  
  8775.  
  8776. When you are satisfied that the programs you have built are working
  8777. correctly, stop the server. Then install MySQL as follows:
  8778.  
  8779.   1. Create the directories where you want to install MySQL.  For
  8780.      example, to install into `C:\mysql', use these commands:
  8781.  
  8782.           C:\> mkdir C:\mysql
  8783.           C:\> mkdir C:\mysql\bin
  8784.           C:\> mkdir C:\mysql\data
  8785.           C:\> mkdir C:\mysql\share
  8786.           C:\> mkdir C:\mysql\scripts
  8787.  
  8788.      If you want to compile other clients and link them to MySQL, you
  8789.      should also create several additional directories:
  8790.  
  8791.           C:\> mkdir C:\mysql\include
  8792.           C:\> mkdir C:\mysql\lib
  8793.           C:\> mkdir C:\mysql\lib\debug
  8794.           C:\> mkdir C:\mysql\lib\opt
  8795.  
  8796.      If you want to benchmark MySQL, create this directory:
  8797.  
  8798.           C:\> mkdir C:\mysql\sql-bench
  8799.  
  8800.      Benchmarking requires Perl support.
  8801.  
  8802.   2. From the `workdir' directory, copy into the `C:\mysql' directory
  8803.      the following directories:
  8804.  
  8805.           C:\> cd \workdir
  8806.           C:\workdir> copy client_release\*.exe C:\mysql\bin
  8807.           C:\workdir> copy client_debug\mysqld.exe C:\mysql\bin\mysqld-debug.exe
  8808.           C:\workdir> xcopy scripts\*.* C:\mysql\scripts /E
  8809.           C:\workdir> xcopy share\*.* C:\mysql\share /E
  8810.  
  8811.      If you want to compile other clients and link them to MySQL, you
  8812.      should also copy several libraries and header files:
  8813.  
  8814.           C:\workdir> copy lib_debug\mysqlclient.lib C:\mysql\lib\debug
  8815.           C:\workdir> copy lib_debug\libmysql.* C:\mysql\lib\debug
  8816.           C:\workdir> copy lib_debug\zlib.* C:\mysql\lib\debug
  8817.           C:\workdir> copy lib_release\mysqlclient.lib C:\mysql\lib\opt
  8818.           C:\workdir> copy lib_release\libmysql.* C:\mysql\lib\opt
  8819.           C:\workdir> copy lib_release\zlib.* C:\mysql\lib\opt
  8820.           C:\workdir> copy include\*.h C:\mysql\include
  8821.           C:\workdir> copy libmysql\libmysql.def C:\mysql\include
  8822.  
  8823.      If you want to benchmark MySQL, you should also do this:
  8824.  
  8825.           C:\workdir> xcopy sql-bench\*.* C:\mysql\bench /E
  8826.  
  8827.  
  8828. Set up and start the server in the same way as for the binary Windows
  8829. distribution.  *Note Windows installation::.
  8830.  
  8831. Creating a Windows Source Package from the Latest Development Source
  8832. ....................................................................
  8833.  
  8834. To create a Windows source package from the current BitKeeper source
  8835. tree, use the following instructions. Please note that this procedure
  8836. must be performed on a system running a Unix or Unix-like operating
  8837. system.  For example, the procedure is known to work well on Linux.
  8838.  
  8839.   1. Clone the BitKeeper source tree for MySQL (version 4.1 or above,
  8840.      as desired).  For more information on how to clone the source tree,
  8841.      see the instructions at *Note Installing source tree::.
  8842.  
  8843.   2. Configure and build the distribution so that you have a server
  8844.      binary to work with.  One way to do this is to run the following
  8845.      command in the top-level directory of your source tree:
  8846.  
  8847.           shell> ./BUILD/compile-pentium-max
  8848.  
  8849.   3. After making sure that the build process completed successfully,
  8850.      run the following utility script from top-level directory of your
  8851.      source tree:
  8852.  
  8853.           shell> ./scripts/make_win_src_distribution
  8854.  
  8855.      This script creates a Windows source package to be used on your
  8856.      Windows system.  You can supply different options to the script
  8857.      based on your needs. It accepts the following options:
  8858.  
  8859.     `--help'
  8860.           Display a help message.
  8861.  
  8862.     `--debug'
  8863.           Print information about script operations, do not create
  8864.           package.
  8865.  
  8866.     `--tmp'
  8867.           Specify the temporary location.
  8868.  
  8869.     `--suffix'
  8870.           Suffix name for the package.
  8871.  
  8872.     `--dirname'
  8873.           Directory name to copy files (intermediate).
  8874.  
  8875.     `--silent'
  8876.           Do not print verbose list of files processed.
  8877.  
  8878.     `--tar'
  8879.           Create `tar.gz' package instead of `.zip' package.
  8880.  
  8881.      By default, `make_win_src_distribution' creates a Zip-format
  8882.      archive with the name `mysql-VERSION-win-src.zip', where VERSION
  8883.      represents the version of your MySQL source tree.
  8884.  
  8885.   4. Copy or upload to your Windows machine the Windows source package
  8886.      that you have just created. To compile it, use the instructions in
  8887.      *Note Windows VC++ Build::.
  8888.  
  8889.  
  8890. Compiling MySQL Clients on Windows
  8891. ----------------------------------
  8892.  
  8893. In your source files, you should include `my_global.h' before `mysql.h':
  8894.  
  8895.      #include <my_global.h>
  8896.      #include <mysql.h>
  8897.  
  8898. `my_global.h' includes any other files needed for Windows compatibility
  8899. (such as `windows.h') if you compile your program on Windows.
  8900.  
  8901. You can either link your code with the dynamic `libmysql.lib' library,
  8902. which is just a wrapper to load in `libmysql.dll' on demand, or link
  8903. with the static `mysqlclient.lib' library.
  8904.  
  8905. The MySQL client libraries are compiled as threaded libraries, so you
  8906. should also compile your code to be multi-threaded.
  8907.  
  8908. Post-Installation Setup and Testing
  8909. ===================================
  8910.  
  8911. After installing MySQL, there are some issues you should address.  For
  8912. example, on Unix, you should initialize the data directory and create
  8913. the MySQL grant tables.  On all platforms, an important security
  8914. concern is that the initial accounts in the grant tables have no
  8915. passwords.  You should assign passwords to prevent unauthorized access
  8916. to the MySQL server.  For MySQL 4.1.3 and up, you can create time zone
  8917. tables to enable recognition of named time zones. (Currently, these
  8918. tables can be populated only on Unix. This problem will be addressed
  8919. soon for Windows.)
  8920.  
  8921. The following sections include post-installation procedures that are
  8922. specific to Windows systems and to Unix systems. Another section, *Note
  8923. Starting server::, applies to all platforms; it describes what to do if
  8924. you have trouble getting the server to start.  *Note Default
  8925. privileges:: also applies to all platforms. You should follow its
  8926. instructions to make sure that you have properly protected your MySQL
  8927. accounts by assigning passwords to them.
  8928.  
  8929. When you are ready to create additional user accounts, you can find
  8930. information on the MySQL access control system and account management in
  8931. *Note Privilege system:: and *Note User Account Management::.
  8932.  
  8933. Windows Post-Installation Procedures
  8934. ------------------------------------
  8935.  
  8936. On Windows, the data directory and the grant tables do not have to be
  8937. created. MySQL Windows distributions include the grant tables already
  8938. set up with a set of preinitialized accounts in the `mysql' database
  8939. under the data directory.  However, you should assign passwords to the
  8940. accounts.  The procedure for this is given in *Note Default
  8941. privileges::.
  8942.  
  8943. Before setting up passwords, you might want to try running some client
  8944. programs to make sure that you can connect to the server and that it is
  8945. operating properly.  Make sure the server is running (*note Windows
  8946. server first start::), then issue the following commands to verify that
  8947. you can retrieve information from the server.  The output should be
  8948. similar to what is shown here:
  8949.  
  8950.      C:\> C:\mysql\bin\mysqlshow
  8951.      +-----------+
  8952.      | Databases |
  8953.      +-----------+
  8954.      | mysql     |
  8955.      | test      |
  8956.      +-----------+
  8957.      
  8958.      C:\> C:\mysql\bin\mysqlshow mysql
  8959.      Database: mysql
  8960.      +--------------+
  8961.      |    Tables    |
  8962.      +--------------+
  8963.      | columns_priv |
  8964.      | db           |
  8965.      | func         |
  8966.      | host         |
  8967.      | tables_priv  |
  8968.      | user         |
  8969.      +--------------+
  8970.      
  8971.      C:\> C:\mysql\bin\mysql -e "SELECT Host,Db,User FROM db" mysql
  8972.      +------+-------+------+
  8973.      | host | db    | user |
  8974.      +------+-------+------+
  8975.      | %    | test% |      |
  8976.      +------+-------+------+
  8977.  
  8978. If you are running a version of Windows that supports services and you
  8979. want the MySQL server to run automatically when Windows starts, see
  8980. *Note NT start::.
  8981.  
  8982. Unix Post-Installation Procedures
  8983. ---------------------------------
  8984.  
  8985. After installing MySQL on Unix, you need to initialize the grant tables,
  8986. start the server, and make sure that the server works okay.  You may
  8987. also wish to arrange for the server to be started and stopped
  8988. automatically when your system starts and stops.  You should also
  8989. assign passwords to the accounts in the grant tables.
  8990.  
  8991. On Unix, the grant tables are set up by the `mysql_install_db' program.
  8992. For some installation methods, this program is run for you
  8993. automatically:
  8994.  
  8995.    * If you install MySQL on Linux using RPM distributions, the server
  8996.      RPM runs `mysql_install_db'.
  8997.  
  8998.    * If you install MySQL on Mac OS X using a PKG distribution, the
  8999.      installer runs `mysql_install_db'.
  9000.  
  9001. Otherwise, you'll need to run `mysql_install_db' yourself.
  9002.  
  9003. The following procedure describes how to initialize the grant tables (if
  9004. that has not already been done) and then start the server. It also
  9005. suggests some commands that you can use to test whether the server is
  9006. accessible and working properly.  For information about starting and
  9007. stopping the server automatically, see *Note Automatic start::.
  9008.  
  9009. After you complete the procedure and have the server running, you should
  9010. assign passwords to the accounts created by `mysql_install_db'.
  9011. Instructions for doing so are given in *Note Default privileges::.
  9012.  
  9013. In the examples shown here, the server runs under the user ID of the
  9014. `mysql' login account. This assumes that such an account exists.
  9015. Either create the account if it does not exist, or substitute the name
  9016. of a different existing login account that you plan to use for running
  9017. the server.
  9018.  
  9019.   1. Change location into the top-level directory of your MySQL
  9020.      installation, represented here by BASEDIR:
  9021.  
  9022.           shell> cd BASEDIR
  9023.  
  9024.      BASEDIR is likely to be something like `/usr/local/mysql' or
  9025.      `/usr/local'.  The following steps assume that you are located in
  9026.      this directory.
  9027.  
  9028.   2. If necessary, run the `mysql_install_db' program to set up the
  9029.      initial MySQL grant tables containing the privileges that
  9030.      determine how users are allowed to connect to the server. You'll
  9031.      need to do this if you used a distribution type that doesn't run
  9032.      the program for you.
  9033.  
  9034.      Typically, `mysql_install_db' needs to be run only the first time
  9035.      you install MySQL, so you can skip this step if you are upgrading
  9036.      an existing installation, However, `mysql_install_db' does not
  9037.      overwrite any existing privilege tables, so it should be safe to
  9038.      run in any circumstances.
  9039.  
  9040.      To initialize the grant tables, use one of the following commands,
  9041.      depending on whether `mysql_install_db' is located in the `bin' or
  9042.      `scripts' directory:
  9043.  
  9044.           shell> bin/mysql_install_db --user=mysql
  9045.           shell> scripts/mysql_install_db --user=mysql
  9046.  
  9047.      The `mysql_install_db' script creates the data directory, the
  9048.      `mysql' database that holds all database privileges, and the `test'
  9049.      database that you can use to test MySQL. The script also creates
  9050.      privilege table entries for `root' accounts and anonymous-user
  9051.      accounts.  The accounts have no passwords initially.  A
  9052.      description of their initial privileges is given in *Note Default
  9053.      privileges::.  Briefly, these privileges allow the MySQL `root'
  9054.      user to do anything, and allow anybody to create or use databases
  9055.      with a name of `test' or starting with `test_'.
  9056.  
  9057.      It is important to make sure that the database directories and
  9058.      files are owned by the `mysql' login account so that the server
  9059.      has read and write access to them when you run it later. To ensure
  9060.      this, the `--user' option should be used as shown if you run
  9061.      `mysql_install_db' as `root'. Otherwise, you should execute the
  9062.      script while logged in as `mysql', in which case you can omit the
  9063.      `--user' option from the command.
  9064.  
  9065.      `mysql_install_db' creates several tables in the `mysql' database:
  9066.      `user', `db', `host', `tables_priv', `columns_priv', `func', and
  9067.      possibly others depending on your version of MySQL.
  9068.  
  9069.      If you don't want to have the `test' database, you can remove it
  9070.      with `mysqladmin -u root drop test' after starting the server.
  9071.  
  9072.      If you have problems with `mysql_install_db', see *Note
  9073.      `mysql_install_db': mysql_install_db.
  9074.  
  9075.      There are some alternatives to running the `mysql_install_db'
  9076.      script as it is provided in the MySQL distribution:
  9077.  
  9078.         * If you want the initial privileges to be different from the
  9079.           standard defaults, you can modify `mysql_install_db' before
  9080.           you run it.  However, a preferable technique is to use
  9081.           `GRANT' and `REVOKE' to change the privileges after the grant
  9082.           tables have been set up.  In other words, you can run
  9083.           `mysql_install_db', and then use `mysql -u root mysql' to
  9084.           connect to the server as the MySQL `root' user so that you
  9085.           can issue the `GRANT' and `REVOKE' statements.
  9086.  
  9087.           If you want to install MySQL on a lot of machines with the
  9088.           same privileges, you can put the `GRANT' and `REVOKE'
  9089.           statements in a file and execute the file as a script using
  9090.           `mysql' after running `mysql_install_db'. For example:
  9091.  
  9092.                shell> bin/mysql_install_db --user=mysql
  9093.                shell> bin/mysql -u root < your_script_file
  9094.  
  9095.           By doing this, you can avoid having to issue the statements
  9096.           manually on each machine.
  9097.  
  9098.         * It is possible to re-create the grant tables completely after
  9099.           they have already been created.  You might want to do this if
  9100.           you're just learning how to use `GRANT' and `REVOKE' and have
  9101.           made so many modifications after running `mysql_install_db'
  9102.           that you want to wipe out the tables and start over.
  9103.  
  9104.           To re-create the grant tables, remove all the `.frm', `.MYI',
  9105.           and `.MYD' files in the directory containing the `mysql'
  9106.           database.  (This is the directory named `mysql' under the
  9107.           data directory, which is listed as the `datadir' value when
  9108.           you run `mysqld --help'.) Then run the `mysql_install_db'
  9109.           script again.
  9110.  
  9111.           *Note*: For MySQL versions older than 3.22.10, you should not
  9112.           delete the `.frm' files.  If you accidentally do this, you
  9113.           should copy them back into the `mysql' directory from your
  9114.           MySQL distribution before running `mysql_install_db'.
  9115.  
  9116.         * You can start `mysqld' manually using the
  9117.           `--skip-grant-tables' option and add the privilege
  9118.           information yourself using `mysql':
  9119.  
  9120.                shell> bin/mysqld_safe --user=mysql --skip-grant-tables &
  9121.                shell> bin/mysql mysql
  9122.  
  9123.           From `mysql', manually execute the SQL commands contained in
  9124.           `mysql_install_db'.  Make sure that you run `mysqladmin
  9125.           flush-privileges' or `mysqladmin reload' afterward to tell
  9126.           the server to reload the grant tables.
  9127.  
  9128.           Note that by not using `mysql_install_db', you not only have
  9129.           to populate the grant tables manually, you also have to
  9130.           create them first.
  9131.  
  9132.   3. Start the MySQL server:
  9133.  
  9134.           shell> bin/mysqld_safe --user=mysql &
  9135.  
  9136.      For versions of MySQL older than 4.0, substitute `bin/safe_mysqld'
  9137.      for `bin/mysqld_safe' in this command.
  9138.  
  9139.      It is important that the MySQL server be run using an unprivileged
  9140.      (non-`root') login account.  To ensure this, the `--user' option
  9141.      should be used as shown if you run `mysql_safe' as `root'.
  9142.      Otherwise, you should execute the script while logged in as
  9143.      `mysql', in which case you can omit the `--user' option from the
  9144.      command.
  9145.  
  9146.      Further instructions for running MySQL as an unprivileged user are
  9147.      given in *Note Changing MySQL user::.
  9148.  
  9149.      If you neglected to create the grant tables before proceeding to
  9150.      this step, the following message will appear in the error log file
  9151.      when you start the server:
  9152.  
  9153.           mysqld: Can't find file: 'host.frm'
  9154.  
  9155.      If you have other problems starting the server, see *Note Starting
  9156.      server::.
  9157.  
  9158.   4. Use `mysqladmin' to verify that the server is running.  The
  9159.      following commands provide simple tests to check whether the
  9160.      server is up and responding to connections:
  9161.  
  9162.           shell> bin/mysqladmin version
  9163.           shell> bin/mysqladmin variables
  9164.  
  9165.      The output from `mysqladmin version' varies slightly depending on
  9166.      your platform and version of MySQL, but should be similar to that
  9167.      shown here:
  9168.  
  9169.           shell> bin/mysqladmin version
  9170.           mysqladmin  Ver 8.40 Distrib 4.0.18, for linux on i586
  9171.           Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
  9172.           This software comes with ABSOLUTELY NO WARRANTY. This is free software,
  9173.           and you are welcome to modify and redistribute it under the GPL license
  9174.           
  9175.           Server version          4.0.18-log
  9176.           Protocol version        10
  9177.           Connection              Localhost via Unix socket
  9178.           TCP port                3306
  9179.           UNIX socket             /tmp/mysql.sock
  9180.           Uptime:                 16 sec
  9181.           
  9182.           Threads: 1  Questions: 9  Slow queries: 0
  9183.           Opens: 7  Flush tables: 2  Open tables: 0
  9184.           Queries per second avg: 0.000
  9185.           Memory in use: 132K  Max memory used: 16773K
  9186.  
  9187.      To see what else you can do with `mysqladmin', invoke it with the
  9188.      `--help' option.
  9189.  
  9190.   5. Verify that you can shut down the server:
  9191.  
  9192.           shell> bin/mysqladmin -u root shutdown
  9193.  
  9194.   6. Verify that you can restart the server.  Do this by using
  9195.      `mysqld_safe' or by invoking `mysqld' directly.  For example:
  9196.  
  9197.           shell> bin/mysqld_safe --user=mysql --log &
  9198.  
  9199.      If `mysqld_safe' fails, see *Note Starting server::.
  9200.  
  9201.   7. Run some simple tests to verify that you can retrieve information
  9202.      from the server.  The output should be similar to what is shown
  9203.      here:
  9204.  
  9205.           shell> bin/mysqlshow
  9206.           +-----------+
  9207.           | Databases |
  9208.           +-----------+
  9209.           | mysql     |
  9210.           | test      |
  9211.           +-----------+
  9212.           
  9213.           shell> bin/mysqlshow mysql
  9214.           Database: mysql
  9215.           +--------------+
  9216.           |    Tables    |
  9217.           +--------------+
  9218.           | columns_priv |
  9219.           | db           |
  9220.           | func         |
  9221.           | host         |
  9222.           | tables_priv  |
  9223.           | user         |
  9224.           +--------------+
  9225.           
  9226.           shell> bin/mysql -e "SELECT Host,Db,User FROM db" mysql
  9227.           +------+--------+------+
  9228.           | host | db     | user |
  9229.           +------+--------+------+
  9230.           | %    | test   |      |
  9231.           | %    | test_% |      |
  9232.           +------+--------+------+
  9233.  
  9234.   8. There is a benchmark suite in the `sql-bench' directory (under the
  9235.      MySQL installation directory) that you can use to compare how
  9236.      MySQL performs on different platforms. The benchmark suite is
  9237.      written in Perl. It uses the Perl DBI module to provide a
  9238.      database-independent interface to the various databases, and some
  9239.      other additional Perl modules are required to run the benchmark
  9240.      suite. You must have the following modules installed:
  9241.  
  9242.           DBI
  9243.           DBD::mysql
  9244.           Data::Dumper
  9245.           Data::ShowTable
  9246.  
  9247.      These modules can be obtained from CPAN (`http://www.cpan.org/').
  9248.      *Note Perl installation::.
  9249.  
  9250.      The `sql-bench/Results' directory contains the results from many
  9251.      runs against different databases and platforms.  To run all tests,
  9252.      execute these commands:
  9253.  
  9254.           shell> cd sql-bench
  9255.           shell> perl run-all-tests
  9256.  
  9257.      If you don't have the `sql-bench' directory, you probably
  9258.      installed MySQL using RPM files other than the source RPM.  (The
  9259.      source RPM includes the `sql-bench' benchmark directory.)  In this
  9260.      case, you must first install the benchmark suite before you can
  9261.      use it.  Beginning with MySQL 3.22, there are separate benchmark
  9262.      RPM files named `mysql-bench-VERSION-i386.rpm' that contain
  9263.      benchmark code and data.
  9264.  
  9265.      If you have a source distribution, there are also tests in its
  9266.      `tests' subdirectory that you can run. For example, to run
  9267.      `auto_increment.tst', execute this command from the top-level
  9268.      directory of your source distribution:
  9269.  
  9270.           shell> mysql -vvf test < ./tests/auto_increment.tst
  9271.  
  9272.      The expected result of the test can be found in the
  9273.      `./tests/auto_increment.res' file.
  9274.  
  9275.   9. At this point, you should have the server running. However, none
  9276.      of the initial MySQL accounts have a password, so you should
  9277.      assign passwords using the instructions in *Note Default
  9278.      privileges::.
  9279.  
  9280. As of MySQL 4.1.3, the installation procedure creates time zone tables
  9281. in the `mysql' database. However, you must populate the tables manually.
  9282. Instructions to do this are given in *Note Time zone support::.
  9283.  
  9284. Problems Running `mysql_install_db'
  9285. ...................................
  9286.  
  9287. The purpose of the `mysql_install_db' script is to generate new MySQL
  9288. privilege tables.  It will not overwrite existing MySQL privilege
  9289. tables, and it will not affect any other data.
  9290.  
  9291. If you want to re-create your privilege tables, first stop the `mysqld'
  9292. server if it's running. Then rename the `mysql' directory under the
  9293. data directory to save it, and then run `mysql_install_db'.  For
  9294. example:
  9295.  
  9296.      shell> mv mysql-data-directory/mysql mysql-data-directory/mysql-old
  9297.      shell> mysql_install_db --user=mysql
  9298.  
  9299. This section lists problems you might encounter when you run
  9300. `mysql_install_db':
  9301.  
  9302. *`mysql_install_db' doesn't install the grant tables*
  9303.      You may find that `mysql_install_db' fails to install the grant
  9304.      tables and terminates after displaying the following messages:
  9305.  
  9306.           Starting mysqld daemon with databases from XXXXXX
  9307.           mysqld ended
  9308.  
  9309.      In this case, you should examine the error log file very
  9310.      carefully.  The log should be located in the directory `XXXXXX'
  9311.      named by the error message, and should indicate why `mysqld'
  9312.      didn't start.  If you don't understand what happened, include the
  9313.      log when you post a bug report.  *Note Bug reports::.
  9314.  
  9315. *There is already a `mysqld' process running*
  9316.      This indicates that the server is already running, in which case
  9317.      the grant tables probably have already been created. If so, you
  9318.      don't have to run `mysql_install_db' at all because it need be run
  9319.      only once (when you install MySQL the first time).
  9320.  
  9321. *Installing a second `mysqld' server doesn't work when one server is running*
  9322.      This can happen when you already have an existing MySQL
  9323.      installation, but want to put a new installation in a different
  9324.      location.  For example, you might have a production installation
  9325.      already, but you want to create a second installation for testing
  9326.      purposes.  Generally the problem that occurs when you try to run a
  9327.      second server is that it tries to use a network interface that is
  9328.      already in use by the first server.  In this case, you will see
  9329.      one of the following error messages:
  9330.  
  9331.           Can't start server: Bind on TCP/IP port:
  9332.           Address already in use
  9333.           Can't start server: Bind on unix socket...
  9334.  
  9335.      For instructions on setting up multiple servers, see *Note
  9336.      Multiple servers::.
  9337.  
  9338. *You don't have write access to `/tmp'*
  9339.      If you don't have write access to create temporary files or a Unix
  9340.      socket file in the default location (the `/tmp' directory), an
  9341.      error will occur when you run `mysql_install_db' or the `mysqld'
  9342.      server.
  9343.  
  9344.      You can specify different temporary directory and Unix socket file
  9345.      locations by executing these commands prior to starting
  9346.      `mysql_install_db' or `mysqld':
  9347.  
  9348.           shell> TMPDIR=/some_tmp_dir/
  9349.           shell> MYSQL_UNIX_PORT=/some_tmp_dir/mysql.sock
  9350.           shell> export TMPDIR MYSQL_UNIX_PORT
  9351.  
  9352.      `some_tmp_dir' should be the full pathname to some directory for
  9353.      which you have write permission.
  9354.  
  9355.      After this, you should be able to run `mysql_install_db' and start
  9356.      the server with these commands:
  9357.  
  9358.           shell> bin/mysql_install_db --user=mysql
  9359.           shell> bin/mysqld_safe --user=mysql &
  9360.  
  9361.      If `mysql_install_db' is located in the `scripts' directory,
  9362.      modify the first command to use `scripts/mysql_install_db'.
  9363.  
  9364.      See *Note Problems with `mysql.sock': Problems with mysql.sock.
  9365.      *Note Environment variables::.
  9366.  
  9367. Starting and Stopping MySQL Automatically
  9368. .........................................
  9369.  
  9370. Generally, you start the `mysqld' server in one of these ways:
  9371.  
  9372.    * By invoking `mysqld' directly. This works on any platform.
  9373.  
  9374.    * By running the MySQL server as a Windows service.  This can be
  9375.      done on versions of Windows that support services (such as NT,
  9376.      2000, and XP). The service can be set to start the server
  9377.      automatically when Windows starts, or as a manual service that you
  9378.      start on request.  For instructions, see *Note NT start::.
  9379.  
  9380.    * By invoking `mysqld_safe', which tries to determine the proper
  9381.      options for `mysqld' and then runs it with those options.  This
  9382.      script is used on systems based on BSD Unix.  *Note `mysqld_safe':
  9383.      mysqld_safe.
  9384.  
  9385.    * By invoking `mysql.server'.  This script is used primarily at
  9386.      system startup and shutdown on systems that use System V-style run
  9387.      directories, where it usually is installed under the name `mysql'.
  9388.      The `mysql.server' script starts the server by invoking
  9389.      `mysqld_safe'.  *Note `mysql.server': mysql.server.
  9390.  
  9391.    * On Mac OS X, you can install a separate MySQL Startup Item package
  9392.      to enable the automatic startup of MySQL on system startup.  The
  9393.      Startup Item starts the server by invoking `mysql.server'.  See
  9394.      *Note Mac OS X installation:: for details.
  9395.  
  9396.  
  9397. The `mysql.server' and `mysqld_safe' scripts and the Mac OS X Startup
  9398. Item can be used to start the server manually, or automatically at
  9399. system startup time. `mysql.server' and the Startup Item also can be
  9400. used to stop the server.
  9401.  
  9402. To start or stop the server manually using the `mysql.server' script,
  9403. invoke it with `start' or `stop' arguments:
  9404.  
  9405.      shell> mysql.server start
  9406.      shell> mysql.server stop
  9407.  
  9408. Before `mysql.server' starts the server, it changes location to the
  9409. MySQL installation directory, and then invokes `mysqld_safe'.  If you
  9410. want the server to run as some specific user, add an appropriate `user'
  9411. option to the `[mysqld]' group of the `/etc/my.cnf' option file, as
  9412. shown later in this section.  (It is possible that you'll need to edit
  9413. `mysql.server' if you've installed a binary distribution of MySQL in a
  9414. non-standard location.  Modify it to `cd' into the proper directory
  9415. before it runs `mysqld_safe'.  If you do this, your modified version of
  9416. `mysql.server' may be overwritten if you upgrade MySQL in the future,
  9417. so you should make a copy of your edited version that you can
  9418. reinstall.)
  9419.  
  9420. `mysql.server stop' brings down the server by sending a signal to it.
  9421. You can also stop the server manually by executing `mysqladmin
  9422. shutdown'.
  9423.  
  9424. To start and stop MySQL automatically on your server, you need to add
  9425. start and stop commands to the appropriate places in your `/etc/rc*'
  9426. files.
  9427.  
  9428. If you use the Linux server RPM package (`MySQL-server-VERSION.rpm'),
  9429. the `mysql.server' script will already have been installed in the
  9430. `/etc/init.d' directory with the name `mysql'. You need not install it
  9431. manually. See *Note Linux-RPM:: for more information on the Linux RPM
  9432. packages.
  9433.  
  9434. Some vendors provide RPM packages that install a startup script under a
  9435. different name such as `mysqld'.
  9436.  
  9437. If you install MySQL from a source distribution or using a binary
  9438. distribution format that does not install `mysql.server' automatically,
  9439. you can install it manually. The script can be found in the
  9440. `support-files' directory under the MySQL installation directory or in
  9441. a MySQL source tree.
  9442.  
  9443. To install `mysql.server' manually, copy it to the `/etc/init.d'
  9444. directory with the name `mysql', and then make it executable.  Do this
  9445. by changing location into the appropriate directory where
  9446. `mysql.server' is located and executing these commands:
  9447.  
  9448.      shell> cp mysql.server /etc/init.d/mysql
  9449.      shell> chmod +x /etc/init.d/mysql
  9450.  
  9451. Older Red Hat systems use the `/etc/rc.d/init.d' directory rather than
  9452. `/etc/init.d'. Adjust the preceding commands accordingly. Alternatively,
  9453. first create `/etc/init.d' as a symbolic link that points to
  9454. `/etc/rc.d/init.d':
  9455.  
  9456.      shell> cd /etc
  9457.      shell> ln -s rc.d/init.d .
  9458.  
  9459. After installing the script, the commands needed to activate it to run
  9460. at system startup depend on your operating system.  On Linux, you can
  9461. use `chkconfig':
  9462.  
  9463.      shell> chkconfig --add mysql
  9464.  
  9465. On some Linux systems, the following command also seems to be necessary
  9466. to fully enable the `mysql' script:
  9467.  
  9468.      shell> chkconfig --level 345 mysql on
  9469.  
  9470. On FreeBSD, startup scripts generally should go in
  9471. `/usr/local/etc/rc.d/'. The `rc(8)' manual page states that scripts in
  9472. this directory are executed only if their basename matches the `*.sh'
  9473. shell filename pattern.  Any other files or directories present within
  9474. the directory are silently ignored. In other words, on FreeBSD, you
  9475. should install the `mysql.server' script as
  9476. `/usr/local/etc/rc.d/mysql.server.sh' to enable automatic startup.
  9477.  
  9478. As an alternative to the preceding setup, some operating systems also
  9479. use `/etc/rc.local' or `/etc/init.d/boot.local' to start additional
  9480. services on startup. To start up MySQL using this method, you could
  9481. append a command like the one following to the appropriate startup file:
  9482.  
  9483.      /bin/sh -c 'cd /usr/local/mysql; ./bin/mysqld_safe --user=mysql &'
  9484.  
  9485. For other systems, consult your operating system documentation to see
  9486. how to install startup scripts.
  9487.  
  9488. You can add options for `mysql.server' in a global `/etc/my.cnf' file.
  9489. A typical `/etc/my.cnf' file might look like this:
  9490.  
  9491.      [mysqld]
  9492.      datadir=/usr/local/mysql/var
  9493.      socket=/var/tmp/mysql.sock
  9494.      port=3306
  9495.      user=mysql
  9496.      
  9497.      [mysql.server]
  9498.      basedir=/usr/local/mysql
  9499.  
  9500. The `mysql.server' script understands the following options: `basedir',
  9501. `datadir', and `pid-file'.  If specified, they _must_ be placed in an
  9502. option file, not on the command line.  `mysql.server' understands only
  9503. `start' and `stop' as command-line arguments.
  9504.  
  9505. The following table shows which option groups the server and each
  9506. startup script read from option files:
  9507.  
  9508. *Script*       *Option Groups*
  9509. `mysqld'       `[mysqld]', `[server]', `[mysqld-major-version]'
  9510. `mysql.server' `[mysqld]', `[mysql.server]'
  9511. `mysqld_safe'  `[mysqld]', `[server]', `[mysqld_safe]'
  9512.  
  9513. `[mysqld-major-version]' means that groups with names like
  9514. `[mysqld-4.0]', `[mysqld-4.1]', and `[mysqld-5.0]' will be read by
  9515. servers having versions 4.0.x, 4.1.x, 5.0.x, and so forth.  This
  9516. feature was added in MySQL 4.0.14. It can be used to specify options
  9517. that will be read only by servers within a given release series.
  9518.  
  9519. For backward compatibility, `mysql.server' also reads the
  9520. `[mysql_server]' group and `mysqld_safe' also reads the `[safe_mysqld]'
  9521. group. However, you should update your option files to use the
  9522. `[mysql.server]' and `[mysqld_safe]' groups instead when you begin
  9523. using MySQL 4.0 or later.
  9524.  
  9525. *Note Option files::.
  9526.  
  9527. Starting and Troubleshooting the MySQL Server
  9528. .............................................
  9529.  
  9530. If you have problems starting the server, here are some things you can
  9531. try:
  9532.  
  9533.    * Specify any special options needed by the storage engines you are
  9534.      using.
  9535.  
  9536.    * Make sure that the server knows where to find the data directory.
  9537.  
  9538.    * Make sure the server can use the data directory.  The ownership and
  9539.      permissions of the data directory and its contents must be set
  9540.      such that the server can access and modify them.
  9541.  
  9542.    * Check the error log to see why the server doesn't start.
  9543.  
  9544.    * Verify that the network interfaces the server wants to use are
  9545.      available.
  9546.  
  9547.  
  9548. Some storage engines have options that control their behavior.  You can
  9549. create a `my.cnf' file and set startup options for the engines you plan
  9550. to use.  If you are going to use storage engines that support
  9551. transactional tables (`InnoDB', `BDB'), be sure that you have them
  9552. configured the way you want before starting the server:
  9553.  
  9554.    * If you are using `InnoDB' tables, refer to the `InnoDB'-specific
  9555.      startup options.  In MySQL 3.23, you must configure `InnoDB'
  9556.      explicitly or the server will fail to start.  From MySQL 4.0 on,
  9557.      `InnoDB' uses default values for its configuration options if you
  9558.      specify none.  *Note `InnoDB' configuration: InnoDB configuration.
  9559.  
  9560.    * If you are using `BDB' (Berkeley DB) tables, you should familiarize
  9561.      yourself with the different `BDB'-specific startup options.  *Note
  9562.      BDB start::.
  9563.  
  9564.  
  9565. When the `mysqld' server starts, it changes location to the data
  9566. directory.  This is where it expects to find databases and where it
  9567. expects to write log files. On Unix, the server also writes the pid
  9568. (process ID) file in the data directory.
  9569.  
  9570. The data directory location is hardwired in when the server is compiled.
  9571. This is where the server looks for the data directory by default. If
  9572. the data directory is located somewhere else on your system, the server
  9573. will not work properly.  You can find out what the default path
  9574. settings are by invoking `mysqld' with the `--verbose' and `--help'
  9575. options.  (Prior to MySQL 4.1, omit the `--verbose' option.)
  9576.  
  9577. If the defaults don't match the MySQL installation layout on your
  9578. system, you can override them by specifying options on the command line
  9579. to `mysqld' or `mysqld_safe'. You can also list the options in an
  9580. option file.
  9581.  
  9582. To specify the location of the data directory explicitly, use the
  9583. `--datadir' option. However, normally you can tell `mysqld' the
  9584. location of the base directory under which MySQL is installed and it
  9585. will look for the data directory there.  You can do this with the
  9586. `--basedir' option.
  9587.  
  9588. To check the effect of specifying path options, invoke `mysqld' with
  9589. those options followed by the `--verbose' and `--help' options.  For
  9590. example, if you change location into the directory where `mysqld' is
  9591. installed, and then run the following command, it will show the effect
  9592. of starting the server with a base directory of `/usr/local':
  9593.  
  9594.      shell> ./mysqld --basedir=/usr/local --verbose --help
  9595.  
  9596. You can specify other options such as `--datadir' as well, but note
  9597. that `--verbose' and `--help' must be the last options.  (Prior to
  9598. MySQL 4.1, omit the `--verbose' option.)
  9599.  
  9600. Once you determine the path settings you want, start the server without
  9601. `--verbose' and `--help'.
  9602.  
  9603. If `mysqld' is currently running, you can find out what path settings
  9604. it is using by executing this command:
  9605.  
  9606.      shell> mysqladmin variables
  9607.  
  9608. Or:
  9609.  
  9610.      shell> mysqladmin -h HOST_NAME variables
  9611.  
  9612. HOST_NAME is the name of the MySQL server host.
  9613.  
  9614. If you get `Errcode 13' (which means `Permission denied') when starting
  9615. `mysqld', this means that the access privileges of the data directory
  9616. or its contents do not allow the server access.  In this case, you
  9617. change the permissions for the involved files and directories so that
  9618. the server has the right to use them.  You can also start the server as
  9619. `root', but this can raise security issues and should be avoided.
  9620.  
  9621. On Unix, change location into the data directory and check the
  9622. ownership of the data directory and its contents to make sure the
  9623. server has access. For example, if the data directory is
  9624. `/usr/local/mysql/var', use this command:
  9625.  
  9626.      shell> ls -la /usr/local/mysql/var
  9627.  
  9628. If the data directory or its files or subdirectories are not owned by
  9629. the account that you use for running the server, change their ownership
  9630. to that account:
  9631.  
  9632.      shell> chown -R mysql /usr/local/mysql/var
  9633.      shell> chgrp -R mysql /usr/local/mysql/var
  9634.  
  9635. If the server fails to start up correctly, check the error log file to
  9636. see if you can find out why.  Log files are located in the data
  9637. directory (typically `C:\mysql\data' on Windows, `/usr/local/mysql/data'
  9638. for a Unix binary distribution, and `/usr/local/var' for a Unix source
  9639. distribution).  Look in the data directory for files with names of the
  9640. form `HOST_NAME.err' and `HOST_NAME.log', where HOST_NAME is the name
  9641. of your server host. (Older servers on Windows use `mysql.err' as the
  9642. error log name.)  Then check the last few lines of these files.  On
  9643. Unix, you can use `tail' to display the last few lines:
  9644.  
  9645.      shell> tail HOST_NAME.err
  9646.      shell> tail HOST_NAME.log
  9647.  
  9648. The error log contains information that indicates why the server
  9649. couldn't start.  For example, you might see something like this in the
  9650. log:
  9651.  
  9652.      000729 14:50:10  bdb:  Recovery function for LSN 1 27595 failed
  9653.      000729 14:50:10  bdb:  warning: ./test/t1.db: No such file or directory
  9654.      000729 14:50:10  Can't init databases
  9655.  
  9656. This means that you didn't start `mysqld' with the `--bdb-no-recover'
  9657. option and Berkeley DB found something wrong with its own log files
  9658. when it tried to recover your databases.  To be able to continue, you
  9659. should move away the old Berkeley DB log files from the database
  9660. directory to some other place, where you can later examine them.  The
  9661. `BDB' log files are named in sequence beginning with `log.0000000001',
  9662. where the number increases over time.
  9663.  
  9664. If you are running `mysqld' with `BDB' table support and `mysqld' dumps
  9665. core at startup, this could be due to problems with the `BDB' recovery
  9666. log.  In this case, you can try starting `mysqld' with
  9667. `--bdb-no-recover'.  If that helps, then you should remove all `BDB'
  9668. log files from the data directory and try starting `mysqld' again
  9669. without the `--bdb-no-recover' option.
  9670.  
  9671. If either of the following errors occur, it means that some other
  9672. program (perhaps another `mysqld' server) is already using the TCP/IP
  9673. port or Unix socket file that `mysqld' is trying to use:
  9674.  
  9675.      Can't start server: Bind on TCP/IP port: Address already in use
  9676.      Can't start server: Bind on unix socket...
  9677.  
  9678. Use `ps' to determine whether you have another `mysqld' server running.
  9679. If so, shut down the server before starting `mysqld' again.  (If
  9680. another server is running, and you really want to run multiple servers,
  9681. you can find information about how to do so in *Note Multiple
  9682. servers::.)
  9683.  
  9684. If no other server is running, try to execute the command `telnet
  9685. your-host-name tcp-ip-port-number'.  (The default MySQL port number is
  9686. 3306.) Then press Enter a couple of times.  If you don't get an error
  9687. message like `telnet: Unable to connect to remote host: Connection
  9688. refused', some other program is using the TCP/IP port that `mysqld' is
  9689. trying to use.  You'll need to track down what program this is and
  9690. disable it, or else tell `mysqld' to listen to a different port with the
  9691. `--port' option.  In this case, you'll also need to specify the port
  9692. number for client programs when connecting to the server via TCP/IP.
  9693.  
  9694. Another reason the port might be inaccessible is that you have a
  9695. firewall running that blocks connections to it. If so, modify the
  9696. firewall settings to allow access to the port.
  9697.  
  9698. If the server starts but you can't connect to it, you should make sure
  9699. that you have an entry in `/etc/hosts' that looks like this:
  9700.  
  9701.      127.0.0.1       localhost
  9702.  
  9703. This problem occurs only on systems that don't have a working thread
  9704. library and for which MySQL must be configured to use MIT-pthreads.
  9705.  
  9706. If you can't get `mysqld' to start, you can try to make a trace file to
  9707. find the problem by using the `--debug' option.  *Note Making trace
  9708. files::.
  9709.  
  9710. Securing the Initial MySQL Accounts
  9711. -----------------------------------
  9712.  
  9713. Part of the MySQL installation process is to set up the `mysql' database
  9714. containing the grant tables:
  9715.  
  9716.    * Windows distributions contain preinitialized grant tables that are
  9717.      installed automatically.
  9718.  
  9719.    * On Unix, the grant tables are populated by the `mysql_install_db'
  9720.      program. Some installation methods run this program for you.
  9721.      Others require that you execute it manually. For details, see
  9722.      *Note Unix post-installation::.
  9723.  
  9724. The grant tables define the initial MySQL user accounts and their access
  9725. privileges.  These accounts are set up as follows:
  9726.  
  9727.    * Two accounts are created with a username of `root'.  These are
  9728.      superuser accounts that can do anything.  The initial `root'
  9729.      account passwords are empty, so anyone can connect to the MySQL
  9730.      server as `root' _without a password_ and be granted all
  9731.      privileges.
  9732.  
  9733.         * On Windows, one `root' account is for connecting from the
  9734.           local host and the other allows connections from any host.
  9735.  
  9736.         * On Unix, both `root' accounts are for connections from the
  9737.           local host.  Connections must be made from the local host by
  9738.           specifying a hostname of `localhost' for one account, or the
  9739.           actual hostname or IP number for the other.
  9740.  
  9741.  
  9742.    * Two anonymous-user accounts are created, each with an empty
  9743.      username.  The anonymous accounts have no passwords, so anyone can
  9744.      use them to connect to the MySQL server.
  9745.  
  9746.         * On Windows, one anonymous account is for connections from the
  9747.           local host.  It has all privileges, just like the `root'
  9748.           accounts.  The other is for connections from any host and has
  9749.           all privileges for the `test' database or other databases
  9750.           with names that start with `test'.
  9751.  
  9752.         * On Unix, both anonymous accounts are for connections from the
  9753.           local host.  Connections must be made from the local host by
  9754.           specifying a hostname of `localhost' for one account, or the
  9755.           actual hostname or IP number for the other.  These accounts
  9756.           have all privileges for the `test' database or other
  9757.           databases with names that start with `test_'.
  9758.  
  9759.  
  9760.  
  9761. As noted, none of the initial accounts have passwords.  This means that
  9762. your MySQL installation is unprotected until you do something about it:
  9763.  
  9764.    * If you want to prevent clients from connecting as anonymous users
  9765.      without a password, you should either assign passwords to the
  9766.      anonymous accounts or else remove them.
  9767.  
  9768.    * You should assign passwords to the MySQL `root' accounts.
  9769.  
  9770.  
  9771. The following instructions describe how to set up passwords for the
  9772. initial MySQL accounts, first for the anonymous accounts and then for
  9773. the `root' accounts.  Replace "NEWPWD" in the examples with the actual
  9774. password that you want to use.  The instructions also cover how to
  9775. remove the anonymous accounts, should you prefer not to allow anonymous
  9776. access at all.
  9777.  
  9778. You might want to defer setting the passwords until later, so that you
  9779. don't need to specify them while you perform additional setup or
  9780. testing.  However, be sure to set them before using your installation
  9781. for any real production work.
  9782.  
  9783. To assign passwords to the anonymous accounts, you can use either `SET
  9784. PASSWORD' or `UPDATE'.  In both cases, be sure to encrypt the password
  9785. using the `PASSWORD()' function.
  9786.  
  9787. To use `SET PASSWORD' on Windows, do this:
  9788.  
  9789.      shell> mysql -u root
  9790.      mysql> SET PASSWORD FOR ''@'localhost' = PASSWORD('NEWPWD');
  9791.      mysql> SET PASSWORD FOR ''@'%' = PASSWORD('NEWPWD');
  9792.  
  9793. To use `SET PASSWORD' on Unix, do this:
  9794.  
  9795.      shell> mysql -u root
  9796.      mysql> SET PASSWORD FOR ''@'localhost' = PASSWORD('NEWPWD');
  9797.      mysql> SET PASSWORD FOR ''@'HOST_NAME' = PASSWORD('NEWPWD');
  9798.  
  9799. In the second `SET PASSWORD' statement, replace HOST_NAME with the name
  9800. of the server host.  This is the name that is specified in the `Host'
  9801. column of the non-`localhost' record for `root' in the `user' table.
  9802. If you don't know what hostname this is, issue the following statement
  9803. before using `SET PASSWORD':
  9804.  
  9805.      mysql> SELECT Host, User FROM mysql.user;
  9806.  
  9807. Look for the record that has `root' in the `User' column and something
  9808. other than `localhost' in the `Host' column. Then use that `Host' value
  9809. in the second `SET PASSWORD' statement.
  9810.  
  9811. The other way to assign passwords to the anonymous accounts is by using
  9812. `UPDATE' to modify the `user' table directly.  Connect to the server as
  9813. `root' and issue an `UPDATE' statement that assigns a value to the
  9814. `Password' column of the appropriate `user' table records.  The
  9815. procedure is the same for Windows and Unix.  The following `UPDATE'
  9816. statement assigns a password to both anonymous accounts at once:
  9817.  
  9818.      shell> mysql -u root
  9819.      mysql> UPDATE mysql.user SET Password = PASSWORD('NEWPWD')
  9820.          ->     WHERE User = '';
  9821.      mysql> FLUSH PRIVILEGES;
  9822.  
  9823. After you update the passwords in the `user' table directly using
  9824. `UPDATE', you must tell the server to re-read the grant tables with
  9825. `FLUSH PRIVILEGES'. Otherwise, the change will go unnoticed until you
  9826. restart the server.
  9827.  
  9828. If you prefer to remove the anonymous accounts instead, do so as
  9829. follows:
  9830.  
  9831.      shell> mysql -u root
  9832.      mysql> DELETE FROM mysql.user WHERE User = '';
  9833.      mysql> FLUSH PRIVILEGES;
  9834.  
  9835. The `DELETE' statement applies both to Windows and to Unix.  On
  9836. Windows, if you want to remove only the anonymous account that has the
  9837. same privileges as `root', do this instead:
  9838.  
  9839.      shell> mysql -u root
  9840.      mysql> DELETE FROM mysql.user WHERE Host='localhost' AND User='';
  9841.      mysql> FLUSH PRIVILEGES;
  9842.  
  9843. This account allows anonymous access but has full privileges, so
  9844. removing it improves security.
  9845.  
  9846. You can assign passwords to the `root' accounts in several ways. The
  9847. following discussion demonstrates three methods:
  9848.  
  9849.    * Use the `SET PASSWORD' statement
  9850.  
  9851.    * Use the `mysqladmin' command-line client program
  9852.  
  9853.    * Use the `UPDATE' statement
  9854.  
  9855. To assign passwords using `SET PASSWORD', connect to the server as
  9856. `root' and issue two `SET PASSWORD' statements.  Be sure to encrypt the
  9857. password using the `PASSWORD()' function.
  9858.  
  9859. For Windows, do this:
  9860.  
  9861.      shell> mysql -u root
  9862.      mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('NEWPWD');
  9863.      mysql> SET PASSWORD FOR 'root'@'%' = PASSWORD('NEWPWD');
  9864.  
  9865. For Unix, do this:
  9866.  
  9867.      shell> mysql -u root
  9868.      mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('NEWPWD');
  9869.      mysql> SET PASSWORD FOR 'root'@'HOST_NAME' = PASSWORD('NEWPWD');
  9870.  
  9871. In the second `SET PASSWORD' statement, replace HOST_NAME with the name
  9872. of the server host.  This is the same hostname that you used when you
  9873. assigned the anonymous account passwords.
  9874.  
  9875. To assign passwords to the `root' accounts using `mysqladmin', execute
  9876. the following commands:
  9877.  
  9878.      shell> mysqladmin -u root password "NEWPWD"
  9879.      shell> mysqladmin -u root -h HOST_NAME password "NEWPWD"
  9880.  
  9881. These commands apply both to Windows and to Unix.  In the second
  9882. command, replace HOST_NAME with the name of the server host.  The double
  9883. quotes around the password are not always necessary, but you should use
  9884. them if the password contains spaces or other characters that are
  9885. special to your command interpreter.
  9886.  
  9887. If you are using a server from a _very_ old version of MySQL, the
  9888. `mysqladmin' commands to set the password will fail with the message
  9889. `parse error near 'SET password''.  The solution to this problem is to
  9890. upgrade the server to a newer version of MySQL.
  9891.  
  9892. You can also use `UPDATE' to modify the `user' table directly.  The
  9893. following `UPDATE' statement assigns a password to both `root' accounts
  9894. at once:
  9895.  
  9896.      shell> mysql -u root
  9897.      mysql> UPDATE mysql.user SET Password = PASSWORD('NEWPWD')
  9898.          ->     WHERE User = 'root';
  9899.      mysql> FLUSH PRIVILEGES;
  9900.  
  9901. The `UPDATE' statement applies both to Windows and to Unix.
  9902.  
  9903. After the passwords have been set, you must supply the appropriate
  9904. password whenever you connect to the server.  For example, if you want
  9905. to use `mysqladmin' to shut down the server, you can do so using this
  9906. command:
  9907.  
  9908.      shell> mysqladmin -u root -p shutdown
  9909.      Enter password: (enter root password here)
  9910.  
  9911. *Note*: If you forget your `root' password after setting it up, the
  9912. procedure for resetting it is covered in *Note Resetting permissions::.
  9913.  
  9914. To set up new accounts, you can use the `GRANT' statement. For
  9915. instructions, see *Note Adding users::.
  9916.  
  9917. Upgrading/Downgrading MySQL
  9918. ===========================
  9919.  
  9920. As a general rule, we recommend that when upgrading from one release
  9921. series to another, you should go to the next series rather than
  9922. skipping a series. For example, if you currently are running MySQL 3.23
  9923. and wish to upgrade to a newer series, upgrade to MySQL 4.0 rather than
  9924. to 4.1 or 5.0.
  9925.  
  9926. The following items form a checklist of things you should do whenever
  9927. you perform an upgrade:
  9928.  
  9929.    * Read the change log for the release series to which you are
  9930.      upgrading to see what new features you can use. For example,
  9931.      before upgrading from MySQL 4.1 to 5.0, read the 5.0 news items.
  9932.      *Note News::.
  9933.  
  9934.    * Before you do an upgrade, back up your databases.
  9935.  
  9936.    * If you are running MySQL Server on Windows, see *Note Windows
  9937.      upgrading::.
  9938.  
  9939.    * An upgrade may involve changes to the grant tables that are stored
  9940.      in the `mysql' database. Occasionally new columns or tables are
  9941.      added to support new features.  To take advantage of these
  9942.      features, be sure that your grant tables are up to date.  The
  9943.      upgrade procedure is described in *Note Upgrading-grant-tables::.
  9944.  
  9945.    * If you are using replication, see *Note Replication Upgrade:: for
  9946.      information on upgrading your replication setup.
  9947.  
  9948.    * If you install a MySQL-Max distribution that includes a server
  9949.      named `mysqld-max', then upgrade later to a non-Max version of
  9950.      MySQL, `mysqld_safe' will still attempt to run the old `mysqld-max'
  9951.      server.  If you perform such an upgrade, you should manually
  9952.      remove the old `mysqld-max' server to ensure that `mysqld_safe'
  9953.      runs the new `mysqld' server.
  9954.  
  9955.  
  9956. You can always move the MySQL format files and data files between
  9957. different versions on the same architecture as long as you stay within
  9958. versions for the same release series of MySQL. The current production
  9959. release series is 4.0. If you change the character set when running
  9960. MySQL, you must run `myisamchk -r -q --set-character-set=CHARSET' on
  9961. all `MyISAM' tables.  Otherwise, your indexes may not be ordered
  9962. correctly, because changing the character set may also change the sort
  9963. order.
  9964.  
  9965. If you upgrade or downgrade from one release series to another, there
  9966. may be incompatibilities in table storage formats. In this case, you
  9967. can use `mysqldump' to dump your tables before upgrading. After
  9968. upgrading, reload the dump file using `mysql' to re-create your tables.
  9969.  
  9970. If you are cautious about using new versions, you can always rename
  9971. your old `mysqld' before installing a newer one. For example, if you
  9972. are using MySQL 4.0.18 and want to upgrade to 4.1.1, rename your
  9973. current server from `mysqld' to `mysqld-4.0.18'.  If your new `mysqld'
  9974. then does something unexpected, you can simply shut it down and restart
  9975. with your old `mysqld'.
  9976.  
  9977. If, after an upgrade, you experience problems with recompiled client
  9978. programs, such as `Commands out of sync' or unexpected core dumps, you
  9979. probably have used old header or library files when compiling your
  9980. programs.  In this case, you should check the date for your `mysql.h'
  9981. file and `libmysqlclient.a' library to verify that they are from the new
  9982. MySQL distribution.  If not, recompile your programs with the new
  9983. headers and libraries.
  9984.  
  9985. If problems occur, such as that the new `mysqld' server doesn't want to
  9986. start or that you can't connect without a password, verify that you
  9987. don't have some old `my.cnf' file from your previous installation.  You
  9988. can check this with the `--print-defaults' option (for example, `mysqld
  9989. --print-defaults').  If this displays anything other than the program
  9990. name, you have an active `my.cnf' file that affects server or client
  9991. operation.
  9992.  
  9993. It is a good idea to rebuild and reinstall the Perl `DBD::mysql' module
  9994. whenever you install a new release of MySQL. The same applies to other
  9995. MySQL interfaces as well, such as the Python `MySQLdb' module.
  9996.  
  9997. Upgrading from Version 4.1 to 5.0
  9998. ---------------------------------
  9999.  
  10000. In general, you should do the following when upgrading to MySQL 5.0
  10001. from 4.1:
  10002.  
  10003.    * Read the 5.0 news items to see what significant new features you
  10004.      can use in 5.0.  *Note News-5.0.x::.
  10005.  
  10006.    * If you are running MySQL Server on Windows, see *Note Windows
  10007.      upgrading::.  Also, two of the Windows MySQL servers were renamed.
  10008.      *Note Windows select server::.
  10009.  
  10010.    * MySQL 5.0 adds support for stored procedures. This support
  10011.      requires the `proc' table in the `mysql' database.  To create this
  10012.      file, you should run the `mysql_fix_privilege_tables' script as
  10013.      described in *Note Upgrading-grant-tables::.
  10014.  
  10015.    * MySQL 5.0 adds support for views. This support requires the extra
  10016.      privilege columns in the `user' and `db' tables in the `mysql'
  10017.      database.  To create these columns, you should run the
  10018.      `mysql_fix_privilege_tables' script as described in *Note
  10019.      Upgrading-grant-tables::.
  10020.  
  10021.    * If you are using replication, see *Note Replication Upgrade:: for
  10022.      information on upgrading your replication setup.
  10023.  
  10024.  
  10025. Upgrading from Version 4.0 to 4.1
  10026. ---------------------------------
  10027.  
  10028. In general, you should do the following when upgrading to MySQL 4.1
  10029. from 4.0:
  10030.  
  10031.    * Check the items in the change lists found later in this section to
  10032.      see whether any of them might affect your applications.
  10033.  
  10034.    * Read the 4.1 news items to see what significant new features you
  10035.      can use in 4.1.  *Note News-4.1.x::.
  10036.  
  10037.    * If you are running MySQL Server on Windows, see *Note Windows
  10038.      upgrading::.
  10039.  
  10040.      *Important note:* Early alpha Windows distributions for MySQL 4.1
  10041.      do not contain an installer program.  See *Note Windows binary
  10042.      installation:: for instructions on how to install such a
  10043.      distribution.
  10044.  
  10045.    * After upgrading, update the grant tables to have the new longer
  10046.      `Password' column that is needed for secure handling of passwords.
  10047.      The procedure uses `mysql_fix_privilege_tables' and is described
  10048.      in *Note Upgrading-grant-tables::.  Implications of the
  10049.      password-handling change for applications are given later in this
  10050.      section.  If you don't do this, MySQL will not us the new more
  10051.      secure protocol to authenticate.
  10052.  
  10053.    * If you are using replication, see *Note Replication Upgrade:: for
  10054.      information on upgrading your replication setup.
  10055.  
  10056.    * The Berkeley DB table handler is updated to DB 4.1 (from 3.2)
  10057.      which has a new log format. If you have to downgrade back to 4.0
  10058.      you must use `mysqldump' to dump your `BDB' tables in text format
  10059.      and delete all `log.XXXXXXXXXX' files before you start MySQL 4.0
  10060.      and reload the data.
  10061.  
  10062.    * Character set support has been improved.  If you have table
  10063.      columns that store character data represented in a character set
  10064.      that the 4.1 server now supports directly, you can convert the
  10065.      columns to the proper character set using the instructions in
  10066.      *Note Charset-conversion::.  Also, database, table, and column
  10067.      identifiers now are stored internally using Unicode (UTF8)
  10068.      regardless of the default character set.  *Note Legal names::.
  10069.  
  10070.    * Starting from MySQL 4.1.3, `InnoDB' uses the same character set
  10071.      comparison functions as MySQL for non-`latin1_swedish_ci'
  10072.      character strings that are not `BINARY'.  This changes the sorting
  10073.      order of space and characters with a code < ASCII(32) in those
  10074.      character sets.  For `latin1_swedish_ci' character strings and
  10075.      `BINARY' strings, `InnoDB' uses its own pad-spaces-at-end
  10076.      comparison method, which stays unchanged.  If you have an `InnoDB'
  10077.      table created with MySQL 4.1.2 or earlier, with an index on a
  10078.      non-`latin1' character set (in the case of 4.1.0 and 4.1.1, with
  10079.      any character set) and the table contains any `CHAR'/`VARCHAR'/or
  10080.      `TEXT' columns that are not `BINARY' but may contain characters
  10081.      with a code < ASCII(32), then you should do `ALTER TABLE' or
  10082.      `OPTIMIZE' table on it to *regenerate the index, after upgrading
  10083.      to MySQL 4.1.3 or later*.
  10084.  
  10085.    * MySQL 4.1.3 introduces support for per-connection time zones.
  10086.      *Note Time zone support::. To enable recognition of named time
  10087.      zones, you should create the time zone tables in the `mysql'
  10088.      database.  For instructions, see *Note Post-installation::.
  10089.  
  10090.    * `mysql_shutdown()' has starting from 4.1.3 an extra parameter:
  10091.      `SHUTDOWN'-level. You should convert any `mysql_shutdown(X)' call
  10092.      you have in your application to
  10093.      `mysql_shutdown(X,SHUTDOWN_DEFAULT)'.
  10094.  
  10095.    * If you are using an old `DBD-mysql' module (`Msql-MySQL-modules')
  10096.      you have to upgrade to use the newer `DBD-mysql' module. Anything
  10097.      above `DBD-mysql' 2.xx should be fine.
  10098.  
  10099.      If you don't upgrade, some methods (such as `DBI->do()') will not
  10100.      notice error conditions correctly.
  10101.  
  10102.    * Option `--defaults-file=option-file-name' will now give an error if
  10103.      the option file doesn't exists.
  10104.  
  10105.    * Some notes about upgrading from MySQL 4.0 to MySQL 4.1 on Netware:
  10106.      Make sure to upgrade Perl and PHP versions. Download and install
  10107.      Perl module for MySQL 4.1 from
  10108.      `http://forge.novell.com/modules/xfmod/project/showfiles.php?group_id=1126'
  10109.      and PHP Extension for MySQL 4.1 from
  10110.      `http://forge.novell.com/modules/xfmod/project/showfiles.php?group_id=1078'.
  10111.  
  10112.  
  10113. Several visible behaviors have changed between MySQL 4.0 and MySQL 4.1
  10114. to fix some critical bugs and make MySQL more compatible with standard
  10115. SQL.  These changes may affect your applications.
  10116.  
  10117. Some of the 4.1 behaviors can be tested in 4.0 before performing a full
  10118. upgrade to 4.1. We have added to later MySQL 4.0 releases (from 4.0.12
  10119. on) a `--new' startup option for `mysqld'.  *Note Server options::.
  10120.  
  10121. This option gives you the 4.1 behavior for the most critical changes.
  10122. You can also enable these behaviors for a given client connection with
  10123. the `SET @@new=1' command, or turn them off if they are on with `SET
  10124. @@new=0'.
  10125.  
  10126. If you believe that some of the 4.1 changes will affect you, we
  10127. recommend that before upgrading to 4.1, you download the latest MySQL
  10128. 4.0 version and run it with the `--new' option by adding the following
  10129. to your config file:
  10130.  
  10131.      [mysqld-4.0]
  10132.      new
  10133.  
  10134. That way you can test the new behaviors in 4.0 to make sure that your
  10135. applications work with them. This will help you have a smooth, painless
  10136. transition when you perform a full upgrade to 4.1 later. Putting the
  10137. `--new' option in the `[mysqld-4.0]' option group ensures that you
  10138. don't accidentally later run the 4.1 version with the `--new' option.
  10139.  
  10140. The following lists describe changes that may affect applications and
  10141. that you should watch out for when upgrading to version 4.1:
  10142.  
  10143. *Server Changes:*
  10144.  
  10145.    * All tables and string columns now have a character set.  *Note
  10146.      Charset::.  Character set information is displayed by `SHOW CREATE
  10147.      TABLE' and `mysqldump'.  (MySQL versions 4.0.6 and above can read
  10148.      the new dump files; older versions cannot.)  This change should
  10149.      not affect applications that use only one character set.
  10150.  
  10151.    * MySQL now interprets length specifications in character column
  10152.      definitions in characters. (Earlier versions interpret them in
  10153.      bytes.)  For example, `CHAR(N)' now means N characters, not N
  10154.      bytes.
  10155.  
  10156.    * The table definition format used in `.frm' files has changed
  10157.      slightly in 4.1.  MySQL 4.0 versions from 4.0.11 on can read the
  10158.      new `.frm' format directly, but older versions cannot.  If you
  10159.      need to move tables from 4.1 to a version earlier than 4.0.11, you
  10160.      should use `mysqldump'.  *Note `mysqldump': mysqldump.
  10161.  
  10162.    * *Important note:* If you upgrade to MySQL 4.1.1 or higher, it is
  10163.      difficult to downgrade back to 4.0 or 4.1.0! That is because, for
  10164.      earlier versions, `InnoDB' is not aware of multiple tablespaces.
  10165.  
  10166.    * Windows servers now support connections from local clients using
  10167.      shared memory if run with the `--shared-memory' option.  If you
  10168.      are running multiple servers this way on the same Windows machine,
  10169.      you should use a different `--shared-memory-base-name' option for
  10170.      each server.
  10171.  
  10172.    * The interface to aggregated UDF functions has changed a bit. You
  10173.      must now declare a `xxx_clear()' function for each aggregate
  10174.      function `XXX()'.
  10175.  
  10176.  
  10177. *Client Changes:*
  10178.  
  10179.    * `mysqldump' now has the `--opt' and `--quote-names' options
  10180.      enabled by default. You can turn them off with `--skip-opt' and
  10181.      `--skip-quote-names'.
  10182.  
  10183.  
  10184. *SQL Changes:*
  10185.  
  10186.    * String comparison now works according to SQL standard: Instead of
  10187.      stripping end spaces before comparison, we now extend the shorter
  10188.      string with spaces.  The problem with this is that now `'a' >
  10189.      'a\t'', which it wasn't before.  If you have any tables where you
  10190.      have a `CHAR' or `VARCHAR' column in which the last character in
  10191.      the column may be less than `ASCII(32)', you should use `REPAIR
  10192.      TABLE' or `myisamchk' to ensure that the table is correct.
  10193.  
  10194.    * When using multiple-table `DELETE' statements, you should use the
  10195.      alias of the tables from which you want to delete, not the actual
  10196.      table name.  For example, instead of doing this:
  10197.  
  10198.           DELETE test FROM test AS t1, test2 WHERE ...
  10199.  
  10200.      Do this:
  10201.  
  10202.           DELETE t1 FROM test AS t1, test2 WHERE ...
  10203.  
  10204.    * `TIMESTAMP' is now returned as a string in `'YYYY-MM-DD HH:MM:SS''
  10205.      format (from 4.0.12 the `--new' option can be used to make a 4.0
  10206.      server behave as 4.1 in this respect).  *Note `TIMESTAMP' 4.1:
  10207.      TIMESTAMP 4.1.
  10208.  
  10209.      If you want to have the value returned as a number (as MySQL 4.0
  10210.      does) you should add `+0' to `TIMESTAMP' columns when you retrieve
  10211.      them:
  10212.  
  10213.           mysql> SELECT ts_col + 0 FROM TBL_NAME;
  10214.  
  10215.      Display widths for `TIMESTAMP' columns are no longer supported.
  10216.      For example, if you declare a column as `TIMESTAMP(10)', the `(10)'
  10217.      is ignored.
  10218.  
  10219.      These changes were necessary for SQL standards compliance. In a
  10220.      future version, a further change will be made (backward compatible
  10221.      with this change), allowing the timestamp length to indicate the
  10222.      desired number of digits for fractions of a second.
  10223.  
  10224.    * Binary values such as `0xFFDF' now are assumed to be strings
  10225.      instead of numbers.  This fixes some problems with character sets
  10226.      where it's convenient to input a string as a binary value.  With
  10227.      this change, you should use `CAST()' if you want to compare binary
  10228.      values numerically as integers:
  10229.  
  10230.           mysql> SELECT CAST(0xFEFF AS UNSIGNED INTEGER)
  10231.               ->        < CAST(0xFF AS UNSIGNED INTEGER);
  10232.                   -> 0
  10233.  
  10234.      If you don't use `CAST()', a lexical string comparison will be
  10235.      done:
  10236.  
  10237.           mysql> SELECT 0xFEFF < 0xFF;
  10238.                   -> 1
  10239.  
  10240.      Using binary items in a numeric context or comparing them using the
  10241.      `=' operator should work as before.  (The `--new' option can be
  10242.      used from 4.0.13 on to make a 4.0 server behave as 4.1 in this
  10243.      respect.)
  10244.  
  10245.    * For functions that produce a `DATE', `DATETIME', or `TIME' value,
  10246.      the result returned to the client now is fixed up to have a
  10247.      temporal type. For example, in MySQL 4.1, you get this result:
  10248.  
  10249.           mysql> SELECT CAST('2001-1-1' AS DATETIME);
  10250.                  -> '2001-01-01 00:00:00'
  10251.  
  10252.      In MySQL 4.0, the result is different:
  10253.  
  10254.           mysql> SELECT CAST('2001-1-1' AS DATETIME);
  10255.                  -> '2001-01-01'
  10256.  
  10257.    * `DEFAULT' values no longer can be specified for `AUTO_INCREMENT'
  10258.      columns. (In 4.0, a `DEFAULT' value is silently ignored; in 4.1,
  10259.      an error occurs.)
  10260.  
  10261.    * `LIMIT' no longer accepts negative arguments.  Use some large
  10262.      number (maximum 18446744073709551615) instead of -1.
  10263.  
  10264.    * `SERIALIZE' is no longer a valid mode value for the `sql_mode'
  10265.      variable.  You should use `SET TRANSACTION ISOLATION LEVEL
  10266.      SERIALIZABLE' instead. `SERIALIZE' is no longer valid for the
  10267.      `--sql-mode' option for `mysqld', either. Use
  10268.      `--transaction-isolation=SERIALIZABLE' instead.
  10269.  
  10270.  
  10271. *C API Changes:*
  10272.  
  10273.    * Some C API calls such as `mysql_real_query()' now return `1' on
  10274.      error, not `-1'.  You may have to change some old applications if
  10275.      they use constructs like this:
  10276.  
  10277.           if (mysql_real_query(mysql_object, query, query_length) == -1)
  10278.           {
  10279.             printf("Got error");
  10280.           }
  10281.  
  10282.      Change the call to test for a non-zero value instead:
  10283.  
  10284.           if (mysql_real_query(mysql_object, query, query_length) != 0)
  10285.           {
  10286.             printf("Got error");
  10287.           }
  10288.  
  10289.  
  10290. *Password-Handling Changes:*
  10291.  
  10292. The password hashing mechanism has changed in 4.1 to provide better
  10293. security, but this may cause compatibility problems if you still have
  10294. clients that use the client library from 4.0 or earlier.  (It is very
  10295. likely that you will have 4.0 clients in situations where clients
  10296. connect from remote hosts that have not yet upgraded to 4.1.)  The
  10297. following list indicates some possible upgrade strategies.  They
  10298. represent various tradeoffs between the goal of compatibility with old
  10299. clients and the goal of security.
  10300.  
  10301.    * Only upgrade the client to use 4.1 client libraries (not the
  10302.      server). No behavior will change (except the return value of some
  10303.      API calls), but you cannot use any of the new features provided by
  10304.      the 4.1 client/server protocol, either.  (MySQL 4.1 has an
  10305.      extended client/server protocol that offers such features as
  10306.      prepared statements and multiple result sets.)  *Note C API
  10307.      Prepared statements::.
  10308.  
  10309.    * Upgrade to 4.1 and run the `mysql_fix_privilege_tables' script to
  10310.      widen the `Password' column in the `user' table so that it can
  10311.      hold long password hashes.  But run the server with the
  10312.      `--old-passwords' option to provide backward compatibility that
  10313.      allows pre-4.1 clients to continue to connect to their short-hash
  10314.      accounts.  Eventually, when all your clients are upgraded to 4.1,
  10315.      you can stop using the `--old-passwords' server option. You can
  10316.      also change the passwords for your MySQL accounts to use the new
  10317.      more secure format.
  10318.  
  10319.    * Upgrade to 4.1 and run the `mysql_fix_privilege_tables' script to
  10320.      widen the `Password' column in the `user' table.  If you know that
  10321.      all clients also have been upgraded to 4.1, don't run the server
  10322.      with the `--old-passwords' option.  Instead, change the passwords
  10323.      on all existing accounts so that they have the new format.  A
  10324.      pure-4.1 installation is the most secure.
  10325.  
  10326.    * Some notes about upgrading from MySQL 4.0 to MySQL 4.1 on Netware:
  10327.      Make sure to upgrade Perl and PHP versions. Download Perl 5 for
  10328.      Netware from http://forge.novell.com/modules/xfmod/project/?perl5)
  10329.      and PHP from http://forge.novell.com/modules/xfmod/project/?php.
  10330.  
  10331.  
  10332. Further background on password hashing with respect to client
  10333. authentication and password-changing operations may be found in *Note
  10334. Password hashing:: and *Note Old client::.
  10335.  
  10336. Upgrading from Version 3.23 to 4.0
  10337. ----------------------------------
  10338.  
  10339. In general, you should do the following when upgrading to MySQL 4.0
  10340. from 3.23:
  10341.  
  10342.    * Check the items in the change lists found later in this section to
  10343.      see whether any of them might affect your applications.
  10344.  
  10345.    * Read the 4.0 news items to see what significant new features you
  10346.      can use in 4.0.  *Note News-4.0.x::.
  10347.  
  10348.    * If you are running MySQL Server on Windows, see *Note Windows
  10349.      upgrading::.
  10350.  
  10351.    * After upgrading, update the grant tables to add new privileges and
  10352.      features.  The procedure uses the `mysql_fix_privilege_tables'
  10353.      script and is described in *Note Upgrading-grant-tables::.
  10354.  
  10355.    * If you are using replication, see *Note Replication Upgrade:: for
  10356.      information on upgrading your replication setup.
  10357.  
  10358.    * Edit any MySQL startup scripts or option files to not use any of
  10359.      the deprecated options described later in this section.
  10360.  
  10361.    * Convert your old `ISAM' files to `MyISAM' files. One way to do this
  10362.      is with the `mysql_convert_table_format' script. (This is a Perl
  10363.      script; it requires that DBI be installed.) To convert the tables
  10364.      in a given database, use this command:
  10365.  
  10366.           shell> mysql_convert_table_format database DB_NAME
  10367.  
  10368.      Note that this should be used only if all tables in the given
  10369.      database are `ISAM' or `MyISAM' tables. To avoid converting tables
  10370.      of other types to `MyISAM', you can explicitly list the names of
  10371.      your `ISAM' tables after the database name on the command line.
  10372.  
  10373.      Individual tables can be changed to `MyISAM' by using the following
  10374.      `ALTER TABLE' statement for each table to be converted:
  10375.  
  10376.           mysql> ALTER TABLE TBL_NAME TYPE=MyISAM;
  10377.  
  10378.      If you are not sure of the table type for a given table, use this
  10379.      statement:
  10380.  
  10381.           mysql> SHOW TABLE STATUS LIKE 'TBL_NAME';
  10382.  
  10383.    * Ensure that you don't have any MySQL clients that use shared
  10384.      libraries (like the Perl `DBD::mysql' module). If you do, you
  10385.      should recompile them, because the data structures used in
  10386.      `libmysqlclient.so' have changed.  The same applies to other MySQL
  10387.      interfaces as well, such as the Python `MySQLdb' module.
  10388.  
  10389.  
  10390. MySQL 4.0 will work even if you don't perform the preceding actions,
  10391. but you will not be able to use the new security privileges in MySQL
  10392. 4.0 and you may run into problems when upgrading later to MySQL 4.1 or
  10393. newer.  The `ISAM' file format still works in MySQL 4.0, but is
  10394. deprecated and is not compiled in by default as of MySQL 4.1. `MyISAM'
  10395. tables should be used instead.
  10396.  
  10397. Old clients should work with a Version 4.0 server without any problems.
  10398.  
  10399. Even if you perform the preceding actions, you can still downgrade to
  10400. MySQL 3.23.52 or newer if you run into problems with the MySQL 4.0
  10401. series.  In this case, you must use `mysqldump' to dump any tables that
  10402. use full-text indexes and reload the dump file into the 3.23 server.
  10403. This is necessary because 4.0 uses a new format for full-text indexing.
  10404.  
  10405. The following lists describe changes that may affect applications and
  10406. that you should watch out for when upgrading to version 4.0:
  10407.  
  10408. *Server Changes:*
  10409.  
  10410.    * MySQL 4.0 has a lot of new privileges in the `mysql.user' table.
  10411.      *Note Privileges provided::.
  10412.  
  10413.      To get these new privileges to work, you must update the grant
  10414.      tables.  The procedure is described in *Note
  10415.      Upgrading-grant-tables::.  Until you do this, all accounts have
  10416.      the `SHOW DATABASES', `CREATE TEMPORARY TABLES', and `LOCK TABLES'
  10417.      privileges. `SUPER' and `EXECUTE' privileges take their value from
  10418.      `PROCESS'.  `REPLICATION SLAVE' and `REPLICATION CLIENT' take their
  10419.      values from `FILE'.
  10420.  
  10421.      If you have any scripts that create new MySQL user accounts, you
  10422.      may want to change them to use the new privileges.  If you are not
  10423.      using `GRANT' commands in the scripts, this is a good time to
  10424.      change your scripts to use `GRANT' instead of modifying the grant
  10425.      tables directly.
  10426.  
  10427.      From version 4.0.2 on, the option `--safe-show-database' is
  10428.      deprecated (and no longer does anything). *Note Privileges
  10429.      options::.
  10430.  
  10431.      If you get `Access denied' errors for new users in version 4.0.2
  10432.      and up, you should check whether you need some of the new grants
  10433.      that you didn't need before.  In particular, you will need
  10434.      `REPLICATION SLAVE' (instead of `FILE') for new slave servers.
  10435.  
  10436.    * `safe_mysqld' has been renamed to `mysqld_safe'.  For backward
  10437.      compatibility, binary distributions will for some time include
  10438.      `safe_mysqld' as a symlink to `mysqld_safe'.
  10439.  
  10440.    * `InnoDB' support is now included by default in binary
  10441.      distributions.  If you build MySQL from source, `InnoDB' is
  10442.      configured in by default.  If you do not use `InnoDB' and want to
  10443.      save memory when running a server that has `InnoDB' support
  10444.      enabled, use the `--skip-innodb' server startup option. To compile
  10445.      MySQL without `InnoDB' support, run `configure' with the
  10446.      `--without-innodb' option.
  10447.  
  10448.    * Values for the startup parameters
  10449.      `myisam_max_extra_sort_file_size' and
  10450.      `myisam_max_extra_sort_file_size' now are given in bytes (they
  10451.      were given in megabytes before 4.0.3).
  10452.  
  10453.    * `mysqld' now has the option `--temp-pool' enabled by default
  10454.      because this gives better performance with some operating systems
  10455.      (most notably Linux).
  10456.  
  10457.    * The `mysqld' startup options `--skip-locking' and
  10458.      `--enable-locking' were renamed to `--skip-external-locking' and
  10459.      `--external-locking'.
  10460.  
  10461.    * External system locking of `MyISAM'/`ISAM' files is now turned off
  10462.      by default.  You can turn this on with `--external-locking'.
  10463.      (However, this is never needed for most users.)
  10464.  
  10465.    * The following startup variables and options have been renamed:
  10466.  
  10467.      *Old Name*                         *New Name*
  10468.      `myisam_bulk_insert_tree_size'     `bulk_insert_buffer_size'
  10469.      `query_cache_startup_type'         `query_cache_type'
  10470.      `record_buffer'                    `read_buffer_size'
  10471.      `record_rnd_buffer'                `read_rnd_buffer_size'
  10472.      `sort_buffer'                      `sort_buffer_size'
  10473.      `warnings'                         `log-warnings'
  10474.      `--err-log'                        `--log-error' (for `mysqld_safe')
  10475.  
  10476.      The startup options `record_buffer', `sort_buffer', and `warnings'
  10477.      will still work in MySQL 4.0 but are deprecated.
  10478.  
  10479. *SQL Changes:*
  10480.  
  10481.    * The following SQL variables have been renamed:
  10482.  
  10483.      *Old Name*                         *New Name*
  10484.      `SQL_BIG_TABLES'                   `BIG_TABLES'
  10485.      `SQL_LOW_PRIORITY_UPDATES'         `LOW_PRIORITY_UPDATES'
  10486.      `SQL_MAX_JOIN_SIZE'                `MAX_JOIN_SIZE'
  10487.      `SQL_QUERY_CACHE_TYPE'             `QUERY_CACHE_TYPE'
  10488.      The old names still work in MySQL 4.0 but are deprecated.
  10489.  
  10490.    * You have to use `SET GLOBAL SQL_SLAVE_SKIP_COUNTER=skip_count'
  10491.      instead of `SET SQL_SLAVE_SKIP_COUNTER=skip_count'.
  10492.  
  10493.    * `SHOW MASTER STATUS' now returns an empty set if binary logging is
  10494.      not enabled.
  10495.  
  10496.    * `SHOW SLAVE STATUS' now returns an empty set if the slave is not
  10497.      initialized.
  10498.  
  10499.    * `SHOW INDEX' has two more columns than it had in 3.23 (`Null' and
  10500.      `Index_type').
  10501.  
  10502.    * The format of `SHOW OPEN TABLES' has changed.
  10503.  
  10504.    * `ORDER BY col_name DESC' sorts `NULL' values last, as of MySQL
  10505.      4.0.11. In 3.23 and in earlier 4.0 versions, this was not always
  10506.      consistent.
  10507.  
  10508.    * `CHECK', `LOCALTIME', and `LOCALTIMESTAMP' now are reserved words.
  10509.  
  10510.    * `DOUBLE' and `FLOAT' columns now honor the `UNSIGNED' flag on
  10511.      storage (before, `UNSIGNED' was ignored for these columns).
  10512.  
  10513.    * The result of all bitwise operators (`|', `&', `<<', `>>', and
  10514.      `~') is now unsigned.  This may cause problems if you are using
  10515.      them in a context where you want a signed result.  *Note Cast
  10516.      Functions::.
  10517.  
  10518.      *Note*: When you use subtraction between integer values where one
  10519.      is of type `UNSIGNED', the result will be unsigned.  In other
  10520.      words, before upgrading to MySQL 4.0, you should check your
  10521.      application for cases in which you are subtracting a value from an
  10522.      unsigned entity and want a negative answer or subtracting an
  10523.      unsigned value from an integer column. You can disable this
  10524.      behavior by using the `--sql-mode=NO_UNSIGNED_SUBTRACTION' option
  10525.      when starting `mysqld'.  *Note Server SQL mode::.
  10526.  
  10527.    * You should use integers to store values in `BIGINT' columns
  10528.      (instead of using strings, as you did in MySQL 3.23).  Using
  10529.      strings will still work, but using integers is more efficient.
  10530.  
  10531.    * In MySQL 3.23, `INSERT INTO ... SELECT' always had `IGNORE'
  10532.      enabled.  As of 4.0.1, MySQL will stop (and possibly roll back) by
  10533.      default in case of an error unless you specify `IGNORE'.
  10534.  
  10535.    * You should use `TRUNCATE TABLE' when you want to delete all rows
  10536.      from a table and you don't need to obtain a count of the number of
  10537.      rows that were deleted.  (`DELETE FROM TBL_NAME' returns a row
  10538.      count in 4.0 and doesn't reset the `AUTO_INCREMENT' counter, and
  10539.      `TRUNCATE TABLE' is faster.)
  10540.  
  10541.    * You will get an error if you have an active transaction or `LOCK
  10542.      TABLES' statement when trying to execute `TRUNCATE TABLE' or `DROP
  10543.      DATABASE'.
  10544.  
  10545.    * To use `MATCH ... AGAINST (... IN BOOLEAN MODE)' full-text searches
  10546.      with your tables, you must rebuild their indexes with `REPAIR TABLE
  10547.      tbl_name USE_FRM'.  If you attempt a boolean full-text search
  10548.      without rebuilding the indexes this way, the search will return
  10549.      incorrect results.  *Note Fulltext Fine-tuning::.
  10550.  
  10551.    * `LOCATE()' and `INSTR()' are case sensitive if one of the
  10552.      arguments is a binary string. Otherwise they are case insensitive.
  10553.  
  10554.    * `STRCMP()' now uses the current character set when performing
  10555.      comparisons.  This makes the default comparison behavior not case
  10556.      sensitive unless one or both of the operands are binary strings.
  10557.  
  10558.    * `HEX(STR)' now returns the characters in STR converted to
  10559.      hexadecimal.  If you want to convert a number to hexadecimal, you
  10560.      should ensure that you call `HEX()' with a numeric argument.
  10561.  
  10562.    * `RAND(seed)' returns a different random number series in 4.0 than
  10563.      in 3.23; this was done to further differentiate `RAND(seed)' and
  10564.      `RAND(seed+1)'.
  10565.  
  10566.    * The default type returned by `IFNULL(A,B)' is now set to be the
  10567.      more "general" of the types of `A' and `B'. (The
  10568.      general-to-specific order is string, `REAL', `INTEGER').
  10569.  
  10570.  
  10571. *C API Changes:*
  10572.  
  10573.    * The old C API functions `mysql_drop_db()', `mysql_create_db()', and
  10574.      `mysql_connect()' are no longer supported unless you compile MySQL
  10575.      with `CFLAGS=-DUSE_OLD_FUNCTIONS'.  However, it is preferable to
  10576.      change client programs to use the new 4.0 API instead.
  10577.  
  10578.    * In the `MYSQL_FIELD' structure, `length' and `max_length' have
  10579.      changed from `unsigned int' to `unsigned long'. This should not
  10580.      cause any problems, except that they may generate warning messages
  10581.      when used as arguments in the `printf()' class of functions.
  10582.  
  10583.    * Multi-threaded clients should use `mysql_thread_init()' and
  10584.      `mysql_thread_end()'. *Note Threaded clients::.
  10585.  
  10586.  
  10587. *Other Changes:*
  10588.  
  10589.    * If you want to recompile the Perl `DBD::mysql' module, use a recent
  10590.      version.  Version 2.9003 is recommended. Versions older than
  10591.      1.2218 should not be used because they use the deprecated
  10592.      `mysql_drop_db()' call.
  10593.  
  10594.  
  10595. Upgrading from Version 3.22 to 3.23
  10596. -----------------------------------
  10597.  
  10598. MySQL 3.22 and 3.21 clients will work without any problems with a MySQL
  10599. 3.23 server.
  10600.  
  10601. When upgrading to MySQL 3.23 from an earlier version, note the following
  10602. changes:
  10603.  
  10604. *Table Changes:*
  10605.  
  10606.    * MySQL 3.23 supports tables of the new `MyISAM' type and the old
  10607.      `ISAM' type.  By default, all new tables are created with type
  10608.      `MyISAM' unless you start `mysqld' with the
  10609.      `--default-table-type=isam' option.  You don't have to convert
  10610.      your old `ISAM' tables to use them with MySQL 3.23.  You can
  10611.      convert an `ISAM' table to `MyISAM' format with `ALTER TABLE
  10612.      TBL_NAME TYPE=MyISAM' or the Perl script
  10613.      `mysql_convert_table_format'.
  10614.  
  10615.    * All tables that use the `tis620' character set must be fixed with
  10616.      `myisamchk -r' or `REPAIR TABLE'.
  10617.  
  10618.    * If you are using the `german' character sort order for `ISAM'
  10619.      tables, you must repair them with `isamchk -r', because we have
  10620.      made some changes in the sort order.
  10621.  
  10622.  
  10623. *Client Program Changes:*
  10624.  
  10625.    * The MySQL client `mysql' is now by default started with the
  10626.      `--no-named-commands (-g)' option. This option can be disabled with
  10627.      `--enable-named-commands (-G)'. This may cause incompatibility
  10628.      problems in some cases--for example, in SQL scripts that use named
  10629.      commands without a semicolon.  Long format commands still work
  10630.      from the first line.
  10631.  
  10632.    * If you want your `mysqldump' files to be compatible between MySQL
  10633.      3.22 and 3.23, you should not use the `--opt' or `--all' option to
  10634.      `mysqldump'.
  10635.  
  10636.  
  10637. *SQL Changes:*
  10638.  
  10639.    * If you do a `DROP DATABASE' on a symbolically linked database,
  10640.      both the link and the original database are deleted.  This didn't
  10641.      happen in MySQL 3.22 because `configure' didn't detect the
  10642.      availability of the `readlink()' system call.
  10643.  
  10644.    * `OPTIMIZE TABLE' now works only for `MyISAM' tables.  For other
  10645.      table types, you can use `ALTER TABLE' to optimize the table.
  10646.      During `OPTIMIZE TABLE', the table is now locked to prevent it
  10647.      from being used by other threads.
  10648.  
  10649.    * Date functions that work on parts of dates (such as `MONTH()')
  10650.      will now return 0 for `0000-00-00' dates. In MySQL 3.22, these
  10651.      functions returned `NULL'.
  10652.  
  10653.    * The default return type of `IF()' now depends on both arguments,
  10654.      not just the first one.
  10655.  
  10656.    * `AUTO_INCREMENT' columns should not be used to store negative
  10657.      numbers. The reason for this is that negative numbers caused
  10658.      problems when wrapping from -1 to 0.  You should not store 0 in
  10659.      `AUTO_INCREMENT' columns, either; `CHECK TABLE' will complain
  10660.      about 0 values because they may change if you dump and restore the
  10661.      table.  `AUTO_INCREMENT' for `MyISAM' tables is now handled at a
  10662.      lower level and is much faster than before. In addition, for
  10663.      `MyISAM' tables, old numbers are no longer reused, even if you
  10664.      delete rows from the table.
  10665.  
  10666.    * `CASE', `DELAYED', `ELSE', `END', `FULLTEXT', `INNER', `RIGHT',
  10667.      `THEN', and `WHEN' now are reserved words.
  10668.  
  10669.    * `FLOAT(p)' now is a true floating-point type and not a value with a
  10670.      fixed number of decimals.
  10671.  
  10672.    * When declaring columns using a `DECIMAL(length,dec)' type, the
  10673.      `length' argument no longer includes a place for the sign or the
  10674.      decimal point.
  10675.  
  10676.    * A `TIME' string must now be of one of the following formats:
  10677.      `[[[DAYS] [H]H:]MM:]SS[.fraction]' or
  10678.      `[[[[[H]H]H]H]MM]SS[.fraction]'.
  10679.  
  10680.    * `LIKE' now compares strings using the same character comparison
  10681.      rules as for the `=' operator.  If you require the old behavior,
  10682.      you can compile MySQL with the `CXXFLAGS=-DLIKE_CMP_TOUPPER' flag.
  10683.  
  10684.    * `REGEXP' now is case insensitive if neither of the strings is a
  10685.      binary string.
  10686.  
  10687.    * When you check or repair `MyISAM' (`.MYI') tables, you should use
  10688.      the `CHECK TABLE' statement or the `myisamchk' command. For `ISAM'
  10689.      (`.ISM') tables, use the `isamchk' command.
  10690.  
  10691.    * Check all your calls to `DATE_FORMAT()' to make sure that there is
  10692.      a `%' before each format character.  (MySQL 3.22 already allowed
  10693.      this syntax, but now `%' is required.)
  10694.  
  10695.    * In MySQL 3.22, the output of `SELECT DISTINCT ...' was almost
  10696.      always sorted.  In MySQL 3.23, you must use `GROUP BY' or `ORDER
  10697.      BY' to obtain sorted output.
  10698.  
  10699.    * `SUM()' now returns `NULL' instead of 0 if there are no matching
  10700.      rows. This is required by standard SQL.
  10701.  
  10702.    * An `AND' or `OR' with `NULL' values will now return `NULL' instead
  10703.      of 0. This mostly affects queries that use `NOT' on an `AND/OR'
  10704.      expression as `NOT NULL' = `NULL'.
  10705.  
  10706.    * `LPAD()' and `RPAD()' now shorten the result string if it's longer
  10707.      than the length argument.
  10708.  
  10709.  
  10710. *C API Changes:*
  10711.  
  10712.    * `mysql_fetch_fields_direct()' now is a function instead of a macro.
  10713.      It now returns a pointer to a `MYSQL_FIELD' instead of a
  10714.      `MYSQL_FIELD'.
  10715.  
  10716.    * `mysql_num_fields()' no longer can be used on a `MYSQL*' object
  10717.      (it's now a function that takes a `MYSQL_RES*' value as an
  10718.      argument). With a `MYSQL*' object, you now should use
  10719.      `mysql_field_count()' instead.
  10720.  
  10721.  
  10722. Upgrading from Version 3.21 to 3.22
  10723. -----------------------------------
  10724.  
  10725. Nothing that affects compatibility has changed between versions 3.21
  10726. and 3.22.  The only pitfall is that new tables that are created with
  10727. `DATE' type columns will use the new way to store the date. You can't
  10728. access these new columns from an old version of `mysqld'.
  10729.  
  10730. When upgrading to MySQL 3.23 from an earlier version, note the following
  10731. changes:
  10732.  
  10733.    * After installing MySQL Version 3.22, you should start the new
  10734.      server and then run the `mysql_fix_privilege_tables' script. This
  10735.      will add the new privileges that you need to use the `GRANT'
  10736.      command.  If you forget this, you will get `Access denied' when
  10737.      you try to use `ALTER TABLE', `CREATE INDEX', or `DROP INDEX'. The
  10738.      procedure for updating the grant tables is described in *Note
  10739.      Upgrading-grant-tables::.
  10740.  
  10741.    * The C API interface to `mysql_real_connect()' has changed.  If you
  10742.      have an old client program that calls this function, you must pass
  10743.      a `0' for the new `db' argument (or recode the client to send the
  10744.      `db' element for faster connections).  You must also call
  10745.      `mysql_init()' before calling `mysql_real_connect()'.  This change
  10746.      was done to allow the new `mysql_options()' function to save
  10747.      options in the `MYSQL' handler structure.
  10748.  
  10749.    * The `mysqld' variable `key_buffer' has been renamed to
  10750.      `key_buffer_size', but you can still use the old name in your
  10751.      startup files.
  10752.  
  10753.  
  10754. Upgrading from Version 3.20 to 3.21
  10755. -----------------------------------
  10756.  
  10757. If you are running a version older than Version 3.20.28 and want to
  10758. switch to Version 3.21, you need to do the following:
  10759.  
  10760. You can start the `mysqld' Version 3.21 server with the
  10761. `--old-protocol' option to use it with clients from a Version 3.20
  10762. distribution.  In this case, the server uses the old pre-3.21
  10763. `password()' checking rather than the new method. Also, the new client
  10764. function `mysql_errno()' will not return any server error, only
  10765. `CR_UNKNOWN_ERROR'. The function does work for client errors.
  10766.  
  10767. If you are _not_ using the `--old-protocol' option to `mysqld', you
  10768. will need to make the following changes:
  10769.  
  10770.    * All client code must be recompiled. If you are using ODBC, you
  10771.      must get the new `MyODBC' 2.x driver.
  10772.  
  10773.    * The `scripts/add_long_password' script must be run to convert the
  10774.      `Password' field in the `mysql.user' table to `CHAR(16)'.
  10775.  
  10776.    * All passwords must be reassigned in the `mysql.user' table to get
  10777.      62-bit rather than 31-bit passwords.
  10778.  
  10779.    * The table format hasn't changed, so you don't have to convert any
  10780.      tables.
  10781.  
  10782.  
  10783. MySQL 3.20.28 and above can handle the new `user' table format without
  10784. affecting clients. If you have a MySQL version earlier than 3.20.28,
  10785. passwords will no longer work with it if you convert the `user' table.
  10786. So to be safe, you should first upgrade to at least Version 3.20.28 and
  10787. then upgrade to Version 3.21.
  10788.  
  10789. The new client code works with a 3.20.x `mysqld' server, so if you
  10790. experience problems with 3.21.x, you can use the old 3.20.x server
  10791. without having to recompile the clients again.
  10792.  
  10793. If you are not using the `--old-protocol' option to `mysqld', old
  10794. clients will be unable to connect and will issue the following error
  10795. message:
  10796.  
  10797.      ERROR: Protocol mismatch. Server Version = 10 Client Version = 9
  10798.  
  10799. The Perl DBI interface also supports the old `mysqlperl' interface.
  10800. The only change you have to make if you use `mysqlperl' is to change
  10801. the arguments to the `connect()' function.  The new arguments are:
  10802. `host', `database', `user', and `password' (note that the `user' and
  10803. `password' arguments have changed places).
  10804.  
  10805. The following changes may affect queries in old applications:
  10806.  
  10807.    * `HAVING' must now be specified before any `ORDER BY' clause.
  10808.  
  10809.    * The parameters to `LOCATE()' have been swapped.
  10810.  
  10811.    * There are some new reserved words. The most noticeable are `DATE',
  10812.      `TIME', and `TIMESTAMP'.
  10813.  
  10814.  
  10815. Upgrading MySQL Under Windows
  10816. -----------------------------
  10817.  
  10818. When upgrading MySQL under Windows, please follow these steps:
  10819.  
  10820.   1. Download the latest Windows distribution of MySQL.
  10821.  
  10822.   2. Choose a time of day with low usage, where a maintenance break is
  10823.      acceptable.
  10824.  
  10825.   3. Alert the users who still are active about the maintenance break.
  10826.  
  10827.   4. Stop the running MySQL Server (for example, with `NET STOP MySQL'
  10828.      or with the `Services' utility if you are running MySQL as a
  10829.      service, or with `mysqladmin shutdown' otherwise).
  10830.  
  10831.   5. Exit the `WinMySQLAdmin' program if it is running.
  10832.  
  10833.   6. Run the installation script of the Windows distribution by
  10834.      clicking the Install button in WinZip and following the
  10835.      installation steps of the script.
  10836.  
  10837.      *Important note:* Early alpha Windows distributions for MySQL 4.1
  10838.      do not contain an installer program.  See *Note Windows binary
  10839.      installation:: for instructions on how to install such a
  10840.      distribution.
  10841.  
  10842.   7. You may either overwrite your old MySQL installation (usually
  10843.      located at `C:\mysql'), or install it into a different directory,
  10844.      such as `C:\mysql4'. Overwriting the old installation is
  10845.      recommended.
  10846.  
  10847.   8. Restart the server. For example, use `NET START MySQL' if you run
  10848.      MySQL as a service, or invoke `mysqld' directly otherwise.
  10849.  
  10850.   9. Update the grant tables. The procedure is described in *Note
  10851.      Upgrading-grant-tables::.
  10852.  
  10853.  
  10854. Possible error situations:
  10855.      A system error has occurred.
  10856.      System error 1067 has occurred.
  10857.      The process terminated unexpectedly.
  10858.  
  10859. These errors mean that your option file (by default `C:\my.cnf')
  10860. contains an option that cannot be recognized by MySQL. You can verify
  10861. that this is the case by trying to restart MySQL with the option file
  10862. renamed to prevent the server from using it. (For example, rename
  10863. `C:\my.cnf' to `C:\my_cnf.old'.)  Once you have verified it, you need
  10864. to identify which option is the culprit. Create a new `my.cnf' file and
  10865. move parts of the old file to it (restarting the server after you move
  10866. each part) until you determine which option causes server startup to
  10867. fail.
  10868.  
  10869. Upgrading the Grant Tables
  10870. --------------------------
  10871.  
  10872. Some releases introduce changes to the structure of the grant tables
  10873. (the tables in the `mysql' database) to add new  privileges or
  10874. features. To make sure that your grant tables are current when you
  10875. update to a new version of MySQL, you should update your grant tables
  10876. as well.
  10877.  
  10878. On Unix or Unix-like systems, update the grant tables by running the
  10879. `mysql_fix_privilege_tables' script:
  10880.  
  10881.      shell> mysql_fix_privilege_tables
  10882.  
  10883. You must run this script while the server is running. It attempts to
  10884. connect to the server running on the local host as `root'.  If your
  10885. `root' account requires a password, indicate the password on the
  10886. command line.  For MySQL 4.1 and up, specify the password like this:
  10887.  
  10888.      shell> mysql_fix_privilege_tables --password=root_password
  10889.  
  10890. Prior to MySQL 4.1, specify the password like this:
  10891.  
  10892.      shell> mysql_fix_privilege_tables root_password
  10893.  
  10894. The `mysql_fix_privilege_tables' script performs any actions necessary
  10895. to convert your grant tables to the current format. You might see some
  10896. `Duplicate column name' warnings as it runs; you can ignore them.
  10897.  
  10898. After running the script, stop the server and restart it.
  10899.  
  10900. On Windows systems, there isn't an easy way to update the grant tables
  10901. until MySQL 4.0.15.  From version 4.0.15 on, MySQL distributions
  10902. include a `mysql_fix_privilege_tables.sql' SQL script that you can run
  10903. using the `mysql' client.  If your MySQL installation is located at
  10904. `C:\mysql', the commands look like this:
  10905.  
  10906.      C:\> C:\mysql\bin\mysql -u root -p mysql
  10907.      mysql> SOURCE C:\mysql\scripts\mysql_fix_privilege_tables.sql
  10908.  
  10909. If your installation is located in some other directory, adjust the
  10910. pathnames appropriately.
  10911.  
  10912. The `mysql' command will prompt you for the `root' password; enter it
  10913. when prompted.
  10914.  
  10915. As with the Unix procedure, you might see some `Duplicate column name'
  10916. warnings as `mysql' processes the statements in the
  10917. `mysql_fix_privilege_tables.sql' script; you can ignore them.
  10918.  
  10919. After running the script, stop the server and restart it.
  10920.  
  10921. If you are upgrading to MySQL 5.0.1 or later, the grant table upgrade
  10922. procedure just described will add view-related columns for the `CREATE
  10923. VIEW' and `SHOW VIEW' privileges. By default, no users will be granted
  10924. these privileges, so you should use the `GRANT' statement to grant
  10925. these privileges manually to any accounts that should have them. Each
  10926. privilege can be granted at the global or database level.
  10927.  
  10928. Copying MySQL Databases to Another Machine
  10929. ------------------------------------------
  10930.  
  10931. If you are using MySQL 3.23 or later, you can copy the `.frm', `.MYI',
  10932. and `.MYD' files for `MyISAM' tables between different architectures
  10933. that support the same floating-point format.  (MySQL takes care of any
  10934. byte-swapping issues.)  *Note `MyISAM' Tables: MyISAM.
  10935.  
  10936. The MySQL `ISAM' data and index files (`.ISD' and `*.ISM',
  10937. respectively) are architecture dependent and in some cases operating
  10938. system dependent.  If you want to move your applications to another
  10939. machine that has a different architecture or operating system than your
  10940. current machine, you should not try to move a database by simply copying
  10941. the files to the other machine. Use `mysqldump' instead.
  10942.  
  10943. By default, `mysqldump' will create a file containing SQL statements.
  10944. You can then transfer the file to the other machine and feed it as input
  10945. to the `mysql' client.
  10946.  
  10947. Try `mysqldump --help' to see what options are available.  If you are
  10948. moving the data to a newer version of MySQL, you should use `mysqldump
  10949. --opt' to take advantage of any optimizations that result in a dump
  10950. file that is smaller and can be processed faster.
  10951.  
  10952. The easiest (although not the fastest) way to move a database between
  10953. two machines is to run the following commands on the machine on which
  10954. the database is located:
  10955.  
  10956.      shell> mysqladmin -h 'OTHER_HOSTNAME' create DB_NAME
  10957.      shell> mysqldump --opt DB_NAME | mysql -h 'OTHER_HOSTNAME' DB_NAME
  10958.  
  10959. If you want to copy a database from a remote machine over a slow
  10960. network, you can use:
  10961.  
  10962.      shell> mysqladmin create DB_NAME
  10963.      shell> mysqldump -h 'OTHER_HOSTNAME' --opt --compress DB_NAME | mysql DB_NAME
  10964.  
  10965. You can also store the result in a file, then transfer the file to the
  10966. target machine and load the file into the database there.  For example,
  10967. you can dump a database to a file on the source machine like this:
  10968.  
  10969.      shell> mysqldump --quick DB_NAME | gzip > DB_NAME.CONTENTS.gz
  10970.  
  10971. (The file created in this example is compressed.) Transfer the file
  10972. containing the database contents to the target machine and run these
  10973. commands there:
  10974.  
  10975.      shell> mysqladmin create DB_NAME
  10976.      shell> gunzip < DB_NAME.CONTENTS.gz | mysql DB_NAME
  10977.  
  10978. You can also use `mysqldump' and `mysqlimport' to transfer the database.
  10979. For big tables, this is much faster than simply using `mysqldump'.  In
  10980. the following commands, `DUMPDIR' represents the full pathname of the
  10981. directory you use to store the output from `mysqldump'.
  10982.  
  10983. First, create the directory for the output files and dump the database:
  10984.  
  10985.      shell> mkdir DUMPDIR
  10986.      shell> mysqldump --tab=DUMPDIR DB_NAME
  10987.  
  10988. Then transfer the files in the `DUMPDIR' directory to some corresponding
  10989. directory on the target machine and load the files into MySQL there:
  10990.  
  10991.      shell> mysqladmin create DB_NAME           # create database
  10992.      shell> cat DUMPDIR/*.sql | mysql DB_NAME   # create tables in database
  10993.      shell> mysqlimport DB_NAME DUMPDIR/*.txt   # load data into tables
  10994.  
  10995. Also, don't forget to copy the `mysql' database because that is where
  10996. the `user', `db', and `host' grant tables are stored.  You might have
  10997. to run commands as the MySQL `root' user on the new machine until you
  10998. have the `mysql' database in place.
  10999.  
  11000. After you import the `mysql' database on the new machine, execute
  11001. `mysqladmin flush-privileges' so that the server reloads the grant table
  11002. information.
  11003.  
  11004. Operating System-Specific Notes
  11005. ===============================
  11006.  
  11007. Linux Notes
  11008. -----------
  11009.  
  11010. This section discusses issues that have been found to occur on Linux.
  11011. The first few subsections describe general operating system-related
  11012. issues, problems that can occur when using binary or source
  11013. distributions, and post-installation issues. The remaining subsections
  11014. discuss problems that occur with Linux on specific platforms.
  11015.  
  11016. Note that most of these problems occur on older versions of Linux. If
  11017. you are running a recent version, you likely will see none of them.
  11018.  
  11019. Linux Operating System Notes
  11020. ............................
  11021.  
  11022. MySQL needs at least Linux Version 2.0.
  11023.  
  11024. *Warning:* We have seen some strange problems with Linux 2.2.14 and
  11025. MySQL on SMP systems.  We also have reports from some MySQL users that
  11026. they have encountered serious stability problems using MySQL with
  11027. kernel 2.2.14.  If you are using this kernel, you should upgrade to
  11028. 2.2.19 (or newer) or to a 2.4 kernel.  If you have a multiple-CPU box,
  11029. then you should seriously consider using 2.4 because it will give you a
  11030. significant speed boost.  Your system also will be more stable.
  11031.  
  11032. When using LinuxThreads, you will see a minimum of three `mysqld'
  11033. processes running.  These are in fact threads.  There will be one
  11034. thread for the LinuxThreads manager, one thread to handle connections,
  11035. and one thread to handle alarms and signals.
  11036.  
  11037. Linux Binary Distribution Notes
  11038. ...............................
  11039.  
  11040. The Linux-Intel binary and RPM releases of MySQL are configured for the
  11041. highest possible speed.  We are always trying to use the fastest stable
  11042. compiler available.
  11043.  
  11044. The binary release is linked with `-static', which means you do not
  11045. normally need to worry about which version of the system libraries you
  11046. have. You need not install LinuxThreads, either.  A program linked with
  11047. `-static' is slightly larger than a dynamically linked program, but
  11048. also slightly faster (3-5%).  However, one problem with a statically
  11049. linked program is that you can't use user-defined functions (UDFs).  If
  11050. you are going to write or use UDFs (this is something for C or C++
  11051. programmers only), you must compile MySQL yourself using dynamic
  11052. linking.
  11053.  
  11054. A known issue with binary distributions is that on older Linux systems
  11055. that use `libc' (such as Red Hat 4.x or Slackware), you will get some
  11056. non-fatal problems with hostname resolution. If your system uses `libc'
  11057. rather than `glibc2', you probably will encounter some difficulties
  11058. with hostname resolution and `getpwnam()'. This happens because `glibc'
  11059. unfortunately depends on some external libraries to implement hostname
  11060. resolution and `getpwent()', even when compiled with `-static'.  These
  11061. problems manifest themselves in two ways:
  11062.  
  11063.    * You probably will see  the following error message when you run
  11064.      `mysql_install_db':
  11065.  
  11066.           Sorry, the host 'XXXX' could not be looked up
  11067.  
  11068.      You can deal with this by executing `mysql_install_db --force',
  11069.      which will not execute the `resolveip' test in `mysql_install_db'.
  11070.      The downside is that you can't use hostnames in the grant tables:
  11071.      Except for `localhost', you must use IP numbers instead.  If you
  11072.      are using an old version of MySQL that doesn't support `--force',
  11073.      you must manually remove the `resolveip' test in `mysql_install'
  11074.      using an editor.
  11075.  
  11076.    * You also may see the following error when you try to run `mysqld'
  11077.      with the `--user' option:
  11078.  
  11079.           getpwnam: No such file or directory
  11080.  
  11081.      To work around this, start `mysqld' by using the `su' command
  11082.      rather than by specifying the `--user' option. This causes the
  11083.      system itself to change the user ID of the `mysqld' process so
  11084.      that `mysqld' need not do so.
  11085.  
  11086.  
  11087. Another solution, which solves both problems, is to not use a binary
  11088. distribution.  Get a MySQL source distribution (in RPM or `tar.gz'
  11089. format) and install that instead.
  11090.  
  11091. On some Linux 2.2 versions, you may get the error `Resource temporarily
  11092. unavailable' when clients make a lot of new connections to a `mysqld'
  11093. server over TCP/IP.  The problem is that Linux has a delay between the
  11094. time that you close a TCP/IP socket and the time that the system
  11095. actually frees it.  There is room for only a finite number of TCP/IP
  11096. slots, so you will encounter the resource-unavailable error if clients
  11097. attempt too many new TCP/IP connections during a short time. For
  11098. example, you may see the error when you run the MySQL `test-connect'
  11099. benchmark over TCP/IP.
  11100.  
  11101. We have inquired about this problem a few times on different Linux
  11102. mailing lists but have never been able to find a suitable resolution.
  11103. The only known "fix" is for the clients to use persistent connections,
  11104. or, if you are running the database server and clients on the same
  11105. machine, to use Unix socket file connections rather than TCP/IP
  11106. connections.
  11107.  
  11108. Linux Source Distribution Notes
  11109. ...............................
  11110.  
  11111. The following notes regarding `glibc' apply only to the situation when
  11112. you build MySQL yourself. If you are running Linux on an x86 machine,
  11113. in most cases it is much better for you to just use our binary. We link
  11114. our binaries against the best patched version of `glibc' we can come up
  11115. with and with the best compiler options, in an attempt to make it
  11116. suitable for a high-load server.  For a typical user, even for setups
  11117. with a lot of concurrent connections or tables exceeding the 2GB limit,
  11118. our binary is the best choice in most cases.  After reading the
  11119. following text, if you are in doubt about what to do, try our binary
  11120. first to see whether it meets your needs.  If you discover that it is
  11121. not good enough, then you may want to try your own build.  In that
  11122. case, we would appreciate a note about it so that we can build a better
  11123. binary next time.
  11124.  
  11125. MySQL uses LinuxThreads on Linux.  If you are using an old Linux
  11126. version that doesn't have `glibc2', you must install LinuxThreads
  11127. before trying to compile MySQL.   You can get LinuxThreads at
  11128. `http://dev.mysql.com/downloads/os-linux.html'.
  11129.  
  11130. Note that `glibc' versions before and including Version 2.1.1 have a
  11131. fatal bug in `pthread_mutex_timedwait()' handling, which is used when
  11132. you issue `INSERT DELAYED' statements.  We recommend that you not use
  11133. `INSERT DELAYED' before upgrading `glibc'.
  11134.  
  11135. Note that Linux kernel and the LinuxThread library can by default only
  11136. have 1,024 threads.  If you plan to have more than 1,000 concurrent
  11137. connections, you will need to make some changes to LinuxThreads:
  11138.  
  11139.    * Increase `PTHREAD_THREADS_MAX' in
  11140.      `sysdeps/unix/sysv/linux/bits/local_lim.h' to 4096 and decrease
  11141.      `STACK_SIZE' in `linuxthreads/internals.h' to 256KB. The paths are
  11142.      relative to the root of `glibc'. (Note that MySQL will not be
  11143.      stable with around 600-1000 connections if `STACK_SIZE' is the
  11144.      default of 2MB.)
  11145.  
  11146.    * Recompile LinuxThreads to produce a new `libpthread.a' library,
  11147.      and relink MySQL against it.
  11148.  
  11149.  
  11150. The page `http://www.volano.com/linuxnotes.html' contains additional
  11151. information about circumventing thread limits in LinuxThreads.
  11152.  
  11153. There is another issue that greatly hurts MySQL performance, especially
  11154. on SMP systems.  The mutex implementation in LinuxThreads in `glibc'
  11155. 2.1 is very bad for programs with many threads that hold the mutex only
  11156. for a short time.  This produces a paradoxical result: If you link
  11157. MySQL against an unmodified LinuxThreads, removing processors from an
  11158. SMP actually improves MySQL performance in many cases.  We have made a
  11159. patch available for `glibc' 2.1.3 to correct this behavior
  11160. (`http://www.mysql.com/Downloads/Linux/linuxthreads-2.1-patch').
  11161.  
  11162. With `glibc' 2.2.2, MySQL 3.23.36 will use the adaptive mutex, which is
  11163. much better than even the patched one in `glibc' 2.1.3. Be warned,
  11164. however, that under some conditions, the current mutex code in `glibc'
  11165. 2.2.2 overspins, which hurts MySQL performance. The likelihood that
  11166. this condition will occur can be reduced by renicing the `mysqld'
  11167. process to the highest priority. We have also been able to correct the
  11168. overspin behavior with a patch, available at
  11169. `http://www.mysql.com/Downloads/Linux/linuxthreads-2.2.2.patch'.  It
  11170. combines the correction of overspin, maximum number of threads, and
  11171. stack spacing all in one. You will need to apply it in the
  11172. `linuxthreads' directory with `patch -p0
  11173. </tmp/linuxthreads-2.2.2.patch'.  We hope it will be included in some
  11174. form in future releases of `glibc' 2.2. In any case, if you link
  11175. against `glibc' 2.2.2, you still need to correct `STACK_SIZE' and
  11176. `PTHREAD_THREADS_MAX'. We hope that the defaults will be corrected to
  11177. some more acceptable values for high-load MySQL setup in the future, so
  11178. that the commands needed to produce your own build can be reduced to
  11179. `./configure; make; make install'.
  11180.  
  11181. We recommend that you use these patches to build a special static
  11182. version of `libpthread.a' and use it only for statically linking
  11183. against MySQL. We know that the patches are safe for MySQL and
  11184. significantly improve its performance, but we cannot say anything about
  11185. other applications. If you link other applications that require
  11186. LinuxThreads against the patched static version of the library, or
  11187. build a patched shared version and install it on your system, you do so
  11188. at your own risk.
  11189.  
  11190. If you experience any strange problems during the installation of
  11191. MySQL, or with some common utilities hanging, it is very likely that
  11192. they are either library or compiler related. If this is the case, using
  11193. our binary will resolve them.
  11194.  
  11195. If you link your own MySQL client programs, you may see the following
  11196. error at runtime:
  11197.  
  11198.      ld.so.1: fatal: libmysqlclient.so.#:
  11199.      open failed: No such file or directory
  11200.  
  11201. This problem can be avoided by one of the following methods:
  11202.  
  11203.    * Link clients with the `-Wl,r/full/path/to/libmysqlclient.so' flag
  11204.      rather than with `-Lpath').
  11205.  
  11206.    * Copy `libmysqclient.so' to `/usr/lib'.
  11207.  
  11208.    * Add the pathname of the directory where `libmysqlclient.so' is
  11209.      located to the `LD_RUN_PATH' environment variable before running
  11210.      your client.
  11211.  
  11212. If you are using the Fujitsu compiler (`fcc/FCC'), you will have some
  11213. problems compiling MySQL because the Linux header files are very `gcc'
  11214. oriented.  The following `configure' line should work with `fcc/FCC':
  11215.  
  11216.      CC=fcc CFLAGS="-O -K fast -K lib -K omitfp -Kpreex -D_GNU_SOURCE \
  11217.          -DCONST=const -DNO_STRTOLL_PROTO" \
  11218.      CXX=FCC CXXFLAGS="-O -K fast -K lib \
  11219.          -K omitfp -K preex --no_exceptions --no_rtti -D_GNU_SOURCE \
  11220.          -DCONST=const -Dalloca=__builtin_alloca -DNO_STRTOLL_PROTO \
  11221.          '-D_EXTERN_INLINE=static __inline'" \
  11222.      ./configure \
  11223.          --prefix=/usr/local/mysql --enable-assembler \
  11224.          --with-mysqld-ldflags=-all-static --disable-shared \
  11225.          --with-low-memory
  11226.  
  11227. Linux Post-Installation Notes
  11228. .............................
  11229.  
  11230. `mysql.server' can be found in the `support-files' directory under the
  11231. MySQL installation directory or in a MySQL source tree.  You can install
  11232. it as `/etc/init.d/mysql' for automatic MySQL startup and shutdown.
  11233. *Note Automatic start::.
  11234.  
  11235. If MySQL can't open enough files or connections, it may be that you
  11236. haven't configured Linux to handle enough files.
  11237.  
  11238. In Linux 2.2 and onward, you can check the number of allocated file
  11239. handles as follows:
  11240.  
  11241.      shell> cat /proc/sys/fs/file-max
  11242.      shell> cat /proc/sys/fs/dquot-max
  11243.      shell> cat /proc/sys/fs/super-max
  11244.  
  11245. If you have more than 16MB of memory, you should add something like the
  11246. following to your init scripts (for example, `/etc/init.d/boot.local'
  11247. on SuSE Linux):
  11248.  
  11249.      echo 65536 > /proc/sys/fs/file-max
  11250.      echo 8192 > /proc/sys/fs/dquot-max
  11251.      echo 1024 > /proc/sys/fs/super-max
  11252.  
  11253. You can also run the `echo' commands from the command line as `root',
  11254. but these settings will be lost the next time your computer restarts.
  11255.  
  11256. Alternatively, you can set these parameters on startup by using the
  11257. `sysctl' tool, which is used by many Linux distributions (SuSE has
  11258. added it as well, beginning with SuSE Linux 8.0). Just put the following
  11259. values into a file named `/etc/sysctl.conf':
  11260.  
  11261.      # Increase some values for MySQL
  11262.      fs.file-max = 65536
  11263.      fs.dquot-max = 8192
  11264.      fs.super-max = 1024
  11265.  
  11266. You should also add the following to `/etc/my.cnf':
  11267.  
  11268.      [mysqld_safe]
  11269.      open-files-limit=8192
  11270.  
  11271. This should allow the server a limit of 8,192 for the combined number of
  11272. connections and open files.
  11273.  
  11274. The `STACK_SIZE' constant in LinuxThreads controls the spacing of thread
  11275. stacks in the address space.  It needs to be large enough so that there
  11276. will be plenty of room for each individual thread stack, but small
  11277. enough to keep the stack of some threads from running into the global
  11278. `mysqld' data.  Unfortunately, as we have experimentally discovered,
  11279. the Linux implementation of `mmap()' will successfully unmap an already
  11280. mapped region if you ask it to map out an address already in use,
  11281. zeroing out the data on the entire page instead of returning an error.
  11282. So, the safety of `mysqld' or any other threaded application depends on
  11283. "gentlemanly" behavior of the code that creates threads.  The user must
  11284. take measures to make sure that the number of running threads at any
  11285. time is sufficiently low for thread stacks to stay away from the global
  11286. heap.  With `mysqld', you should enforce this behavior by setting a
  11287. reasonable value for the `max_connections' variable.
  11288.  
  11289. If you build MySQL yourself, you can patch LinuxThreads for better
  11290. stack use.  *Note Source notes-Linux::.  If you do not want to patch
  11291. LinuxThreads, you should set `max_connections' to a value no higher
  11292. than 500.  It should be even less if you have a large key buffer,  large
  11293. heap tables, or some other things that make `mysqld' allocate a lot of
  11294. memory, or if you are running a 2.2 kernel with a 2GB patch. If you are
  11295. using our binary or RPM version 3.23.25 or later, you can safely set
  11296. `max_connections' at 1500, assuming no large key buffer or heap tables
  11297. with lots of data.  The more you reduce `STACK_SIZE' in LinuxThreads
  11298. the more threads you can safely create.  We recommend values between
  11299. 128KB and 256KB.
  11300.  
  11301. If you use a lot of concurrent connections, you may suffer from a
  11302. "feature" in the 2.2 kernel that attempts to prevent fork bomb attacks
  11303. by penalizing a process for forking or cloning a child.  This causes
  11304. MySQL not to scale well as you increase the number of concurrent
  11305. clients.  On single-CPU systems, we have seen this manifested as very
  11306. slow thread creation: It may take a long time to connect to MySQL (as
  11307. long as one minute), and it may take just as long to shut it down.  On
  11308. multiple-CPU systems, we have observed a gradual drop in query speed as
  11309. the number of clients increases.  In the process of trying to find a
  11310. solution, we have received a kernel patch from one of our users who
  11311. claimed it made a lot of difference for his site.  The patch is
  11312. available at `http://www.mysql.com/Downloads/Patches/linux-fork.patch'.
  11313. We have now done rather extensive testing of this patch on both
  11314. development and production systems.  It has significantly improved
  11315. MySQL performance without causing any problems and we now recommend it
  11316. to our users who still run high-load servers on 2.2 kernels.
  11317.  
  11318. This issue has been fixed in the 2.4 kernel, so if you are not satisfied
  11319. with the current performance of your system, rather than patching your
  11320. 2.2 kernel, it might be easier to upgrade to 2.4. On SMP systems,
  11321. upgrading also will give you a nice SMP boost in addition to fixing the
  11322. fairness bug.
  11323.  
  11324. We have tested MySQL on the 2.4 kernel on a two-CPU machine and found
  11325. MySQL scales _much_ better. There was virtually no slowdown on query
  11326. throughput all the way up to 1,000 clients, and the MySQL scaling factor
  11327. (computed as the ratio of maximum throughput to the throughput for one
  11328. client) was 180%.  We have observed similar results on a four-CPU
  11329. system: Virtually no slowdown as the number of clients was increased up
  11330. to 1,000, and a 300% scaling factor. Based on these results, for a
  11331. high-load SMP server using a 2.2 kernel, we definitely recommend
  11332. upgrading to the 2.4 kernel at this point.
  11333.  
  11334. We have discovered that it is essential to run the `mysqld' process
  11335. with the highest possible priority on the 2.4 kernel to achieve maximum
  11336. performance.  This can be done by adding a `renice -20 $$' command to
  11337. `mysqld_safe'. In our testing on a four-CPU machine, increasing the
  11338. priority resulted in a 60% throughput increase with 400 clients.
  11339.  
  11340. We are currently also trying to collect more information on how well
  11341. MySQL performs with a 2.4 kernel on four-way and eight-way systems. If
  11342. you have access such a system and have done some benchmarks, please
  11343. send an email message to <benchmarks@mysql.com> with the results. We
  11344. will review them for inclusion in the manual.
  11345.  
  11346. If you see a dead `mysqld' server process with `ps', this usually means
  11347. that you have found a bug in MySQL or you have a corrupted table. *Note
  11348. Crashing::.
  11349.  
  11350. To get a core dump on Linux if `mysqld' dies with a `SIGSEGV' signal,
  11351. you can start `mysqld' with the `--core-file' option.  Note that you
  11352. also probably need to raise the core file size by adding `ulimit -c
  11353. 1000000' to `mysqld_safe' or starting `mysqld_safe' with
  11354. `--core-file-size=1000000'.  *Note `mysqld_safe': mysqld_safe.
  11355.  
  11356. Linux x86 Notes
  11357. ...............
  11358.  
  11359. MySQL requires `libc' Version 5.4.12 or newer. It's known to work with
  11360. `libc' 5.4.46.  `glibc' Version 2.0.6 and later should also work. There
  11361. have been some problems with the `glibc' RPMs from Red Hat, so if you
  11362. have problems, check whether there are any updates.  The `glibc'
  11363. 2.0.7-19 and 2.0.7-29 RPMs are known to work.
  11364.  
  11365. If you are using Red Hat 8.0 or a new `glibc' 2.2.x library, you may see
  11366. `mysqld' die in `gethostbyaddr()'. This happens because the new `glibc'
  11367. library requires a stack size greater than 128KB for this call.  To fix
  11368. the problem, start `mysqld' with the `--thread-stack=192K' option.
  11369. (Use `-O thread_stack=192K' before MySQL 4.)  This stack size is now
  11370. the default on MySQL 4.0.10 and above, so you should not see the
  11371. problem.
  11372.  
  11373. If you are using `gcc' 3.0 and above to compile MySQL, you must install
  11374. the `libstdc++v3' library before compiling MySQL; if you don't do this,
  11375. you will get an error about a missing `__cxa_pure_virtual' symbol
  11376. during linking.
  11377.  
  11378. On some older Linux distributions, `configure' may produce an error
  11379. like this:
  11380.  
  11381.      Syntax error in sched.h. Change _P to __P in the
  11382.      /usr/include/sched.h file.
  11383.      See the Installation chapter in the Reference Manual.
  11384.  
  11385. Just do what the error message says. Add an extra underscore to the
  11386. `_P' macro name that has only one underscore, then try again.
  11387.  
  11388. You may get some warnings when compiling. Those shown here can be
  11389. ignored:
  11390.  
  11391.      mysqld.cc -o objs-thread/mysqld.o
  11392.      mysqld.cc: In function `void init_signals()':
  11393.      mysqld.cc:315: warning: assignment of negative value `-1' to
  11394.      `long unsigned int'
  11395.      mysqld.cc: In function `void * signal_hand(void *)':
  11396.      mysqld.cc:346: warning: assignment of negative value `-1' to
  11397.      `long unsigned int'
  11398.  
  11399. If `mysqld' always dumps core when it starts, the problem may be that
  11400. you have an old `/lib/libc.a'.  Try renaming it, then remove
  11401. `sql/mysqld' and do a new `make install' and try again.  This problem
  11402. has been reported on some Slackware installations.
  11403.  
  11404. If you get the following error when linking `mysqld', it means that
  11405. your `libg++.a' is not installed correctly:
  11406.  
  11407.      /usr/lib/libc.a(putc.o): In function `_IO_putc':
  11408.      putc.o(.text+0x0): multiple definition of `_IO_putc'
  11409.  
  11410. You can avoid using `libg++.a' by running `configure' like this:
  11411.  
  11412.      shell> CXX=gcc ./configure
  11413.  
  11414. If `mysqld' crashes immediately and you are running Red Hat Version 5.0
  11415. with a version of `glibc' older than 2.0.7-5, you should make sure that
  11416. you have installed all `glibc' patches.  There is a lot of information
  11417. about this in the MySQL mail archives, available online at
  11418. `http://lists.mysql.com/'.
  11419.  
  11420. Linux SPARC Notes
  11421. .................
  11422.  
  11423. In some implementations, `readdir_r()' is broken.  The symptom is that
  11424. the `SHOW DATABASES' statement always returns an empty set.  This can
  11425. be fixed by removing `HAVE_READDIR_R' from `config.h' after configuring
  11426. and before compiling.
  11427.  
  11428. Linux Alpha Notes
  11429. .................
  11430.  
  11431. MySQL 3.23.12 is the first MySQL version that is tested on Linux-Alpha.
  11432. If you plan to use MySQL on Linux-Alpha, you should ensure that you
  11433. have this version or newer.
  11434.  
  11435. We have tested MySQL on Alpha with our benchmarks and test suite, and
  11436. it appears to work nicely.
  11437.  
  11438. We currently build the MySQL binary packages on SuSE Linux 7.0 for AXP,
  11439. kernel 2.4.4-SMP, Compaq C compiler (V6.2-505) and Compaq C++ compiler
  11440. (V6.3-006) on a Compaq DS20 machine with an Alpha EV6 processor.
  11441.  
  11442. You can find the preceding compilers at
  11443. `http://www.support.compaq.com/alpha-tools/'.  By using these compilers
  11444. rather than `gcc', we get about 9-14% better MySQL performance.
  11445.  
  11446. Note that until MySQL version 3.23.52 and 4.0.2, we optimized the
  11447. binary for the current CPU only (by using the `-fast' compile option).
  11448. This means that for older versions, you can use our Alpha binaries only
  11449. if you have an Alpha EV6 processor.
  11450.  
  11451. For all following releases, we added the `-arch generic' flag to our
  11452. compile options, which makes sure that the binary runs on all Alpha
  11453. processors. We also compile statically to avoid library problems.  The
  11454. `configure' command looks like this:
  11455.  
  11456.      CC=ccc CFLAGS="-fast -arch generic" CXX=cxx \
  11457.      CXXFLAGS="-fast -arch generic -noexceptions -nortti" \
  11458.      ./configure --prefix=/usr/local/mysql --disable-shared \
  11459.          --with-extra-charsets=complex --enable-thread-safe-client \
  11460.          --with-mysqld-ldflags=-non_shared --with-client-ldflags=-non_shared
  11461.  
  11462. If you want to use `egcs', the following `configure' line worked for us:
  11463.  
  11464.      CFLAGS="-O3 -fomit-frame-pointer" CXX=gcc \
  11465.      CXXFLAGS="-O3 -fomit-frame-pointer -felide-constructors \
  11466.          -fno-exceptions -fno-rtti" \
  11467.      ./configure --prefix=/usr/local/mysql --disable-shared
  11468.  
  11469. Some known problems when running MySQL on Linux-Alpha:
  11470.  
  11471.    * Debugging threaded applications like MySQL will not work with `gdb
  11472.      4.18'.  You should use `gdb' 5.1 instead.
  11473.  
  11474.    * If you try linking `mysqld' statically when using `gcc', the
  11475.      resulting image will dump core at startup time.  In other words,
  11476.      _do not_ use `--with-mysqld-ldflags=-all-static' with `gcc'.
  11477.  
  11478. Linux PowerPC Notes
  11479. ...................
  11480.  
  11481. MySQL should work on MkLinux with the newest `glibc' package (tested
  11482. with `glibc' 2.0.7).
  11483.  
  11484. Linux MIPS Notes
  11485. ................
  11486.  
  11487. To get MySQL to work on Qube2 (Linux Mips), you need the newest `glibc'
  11488. libraries. `glibc-2.0.7-29C2' is known to work.  You must also use the
  11489. `egcs' C++ compiler (`egcs' 1.0.2-9, `gcc' 2.95.2 or newer).
  11490.  
  11491. Linux IA-64 Notes
  11492. .................
  11493.  
  11494. To get MySQL to compile on Linux IA-64, we use the following `configure'
  11495. command for building with `gcc' 2.96:
  11496.  
  11497.      CC=gcc \
  11498.      CFLAGS="-O3 -fno-omit-frame-pointer" \
  11499.      CXX=gcc \
  11500.      CXXFLAGS="-O3 -fno-omit-frame-pointer -felide-constructors \
  11501.          -fno-exceptions -fno-rtti" \
  11502.          ./configure --prefix=/usr/local/mysql \
  11503.          "--with-comment=Official MySQL binary" \
  11504.          --with-extra-charsets=complex
  11505.  
  11506. On IA-64, the MySQL client binaries use shared libraries. This means
  11507. that if you install our binary distribution at a location other than
  11508. `/usr/local/mysql', you need to add the path of the directory where you
  11509. have `libmysqlclient.so' installed either to the `/etc/ld.so.conf' file
  11510. or to the value of your `LD_LIBRARY_PATH' environment variable.
  11511.  
  11512. *Note Link errors::.
  11513.  
  11514. Mac OS X Notes
  11515. --------------
  11516.  
  11517. On Mac OS X, `tar' cannot handle long filenames. If you need to unpack a
  11518. `.tar.gz' distribution, use `gnutar' instead.
  11519.  
  11520. Mac OS X 10.x (Darwin)
  11521. ......................
  11522.  
  11523. MySQL should work without any problems on Mac OS X 10.x (Darwin).
  11524.  
  11525. Our binary for Mac OS X is compiled on Darwin 6.3 with the following
  11526. `configure' line:
  11527.  
  11528.      CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc \
  11529.      CXXFLAGS="-O3 -fno-omit-frame-pointer -felide-constructors \
  11530.          -fno-exceptions -fno-rtti" \
  11531.          ./configure --prefix=/usr/local/mysql \
  11532.          --with-extra-charsets=complex --enable-thread-safe-client \
  11533.          --enable-local-infile --disable-shared
  11534.  
  11535. *Note Mac OS X installation::.
  11536.  
  11537. Mac OS X Server 1.2 (Rhapsody)
  11538. ..............................
  11539.  
  11540. For current versions of Mac OS X Server, no operating system changes are
  11541. necessary before compiling MySQL.  Compiling for the Server platform is
  11542. the same as for the client version of Mac OS X. (However, note that
  11543. MySQL comes preinstalled on Mac OS X Server, so you need not build it
  11544. yourself.)
  11545.  
  11546. For older versions (Mac OS X Server 1.2, a.k.a. Rhapsody), you must
  11547. first install a pthread package before trying to configure MySQL.
  11548.  
  11549. *Note Mac OS X installation::.
  11550.  
  11551. Solaris Notes
  11552. -------------
  11553.  
  11554. On Solaris, you may run into trouble even before you get the MySQL
  11555. distribution unpacked!  Solaris `tar' can't handle long filenames, so
  11556. you may see an error like this when you unpack MySQL:
  11557.  
  11558.      x mysql-3.22.12-beta/bench/Results/ATIS-mysql_odbc-NT_4.0-cmp-db2,
  11559.      informix,ms-sql,mysql,oracle,solid,sybase, 0 bytes, 0 tape blocks
  11560.      tar: directory checksum error
  11561.  
  11562. In this case, you must use GNU `tar' (`gtar') to unpack the
  11563. distribution.  You can find a precompiled copy for Solaris at
  11564. `http://dev.mysql.com/downloads/os-solaris.html'.
  11565.  
  11566. Sun native threads work only on Solaris 2.5 and higher.  For Version
  11567. 2.4 and earlier, MySQL automatically uses MIT-pthreads.  *Note
  11568. MIT-pthreads::.
  11569.  
  11570. If you get the following error from `configure', it means that you have
  11571. something wrong with your compiler installation:
  11572.  
  11573.      checking for restartable system calls... configure: error can not
  11574.      run test programs while cross compiling
  11575.  
  11576. In this case, you should upgrade your compiler to a newer version.  You
  11577. may also be able to solve this problem by inserting the following row
  11578. into the `config.cache' file:
  11579.  
  11580.      ac_cv_sys_restartable_syscalls=${ac_cv_sys_restartable_syscalls='no'}
  11581.  
  11582. If you are using Solaris on a SPARC, the recommended compiler is `gcc'
  11583. 2.95.2 or 3.2. You can find this at `http://gcc.gnu.org/'.  Note that
  11584. `egcs' 1.1.1 and `gcc' 2.8.1 don't work reliably on SPARC!
  11585.  
  11586. The recommended `configure' line when using `gcc' 2.95.2 is:
  11587.  
  11588.      CC=gcc CFLAGS="-O3" \
  11589.      CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti" \
  11590.      ./configure --prefix=/usr/local/mysql --with-low-memory \
  11591.          --enable-assembler
  11592.  
  11593. If you have an UltraSPARC system, you can get 4% better performance by
  11594. adding `-mcpu=v8 -Wa,-xarch=v8plusa' to the `CFLAGS' and `CXXFLAGS'
  11595. environment variables.
  11596.  
  11597. If you have Sun's Forte 5.0 (or newer) compiler, you can run
  11598. `configure' like this:
  11599.  
  11600.      CC=cc CFLAGS="-Xa -fast -native -xstrconst -mt" \
  11601.      CXX=CC CXXFLAGS="-noex -mt" \
  11602.      ./configure --prefix=/usr/local/mysql --enable-assembler
  11603.  
  11604. To create a 64-bit binary with Sun's Forte compiler, use the following
  11605. configuration options:
  11606.  
  11607.      CC=cc CFLAGS="-Xa -fast -native -xstrconst -mt -xarch=v9" \
  11608.      CXX=CC CXXFLAGS="-noex -mt -xarch=v9" ASFLAGS="-xarch=v9" \
  11609.      ./configure --prefix=/usr/local/mysql --enable-assembler
  11610.  
  11611. To create a 64-bit Solaris binary using `gcc', add `-m64' to `CFLAGS'
  11612. and `CXXFLAGS' and remove `--enable-assembler' from the `configure'
  11613. line. This works only with MySQL 4.0 and up; MySQL 3.23 does not
  11614. include the required modifications to support this.
  11615.  
  11616. In the MySQL benchmarks, we got a 4% speedup on an UltraSPARC when using
  11617. Forte 5.0 in 32-bit mode compared to using `gcc' 3.2 with the `-mcpu'
  11618. flag.
  11619.  
  11620. If you create a 64-bit `mysqld' binary, it is 4% slower than the 32-bit
  11621. binary, but can handle more threads and memory.
  11622.  
  11623. If you get a problem with `fdatasync' or `sched_yield', you can fix
  11624. this by adding `LIBS=-lrt' to the `configure' line
  11625.  
  11626. For compilers older than WorkShop 5.3, you might have to edit the
  11627. `configure' script. Change this line:
  11628.  
  11629.      #if !defined(__STDC__) || __STDC__ != 1
  11630.  
  11631. To this:
  11632.  
  11633.      #if !defined(__STDC__)
  11634.  
  11635. If you turn on `__STDC__' with the `-Xc' option, the Sun compiler can't
  11636. compile with the Solaris `pthread.h' header file.  This is a Sun bug
  11637. (broken compiler or broken include file).
  11638.  
  11639. If `mysqld' issues the following error message when you run it, you have
  11640. tried to compile MySQL with the Sun compiler without enabling the `-mt'
  11641. multi-thread option:
  11642.  
  11643.      libc internal error: _rmutex_unlock: rmutex not held
  11644.  
  11645. Add `-mt' to `CFLAGS' and `CXXFLAGS' and recompile.
  11646.  
  11647. If you are using the SFW version of `gcc' (which comes with Solaris 8),
  11648. you must add `/opt/sfw/lib' to the environment variable
  11649. `LD_LIBRARY_PATH' before running `configure'.
  11650.  
  11651. If you are using the `gcc' available from `sunfreeware.com', you may
  11652. have many problems.  To avoid this, you should recompile `gcc' and GNU
  11653. `binutils' on the machine where you will be running them.
  11654.  
  11655. If you get the following error when compiling MySQL with `gcc', it
  11656. means that your `gcc' is not configured for your version of Solaris:
  11657.  
  11658.      shell> gcc -O3 -g -O2 -DDBUG_OFF  -o thr_alarm ...
  11659.      ./thr_alarm.c: In function `signal_hand':
  11660.      ./thr_alarm.c:556: too many arguments to function `sigwait'
  11661.  
  11662. The proper thing to do in this case is to get the newest version of
  11663. `gcc' and compile it with your current `gcc' compiler.  At least for
  11664. Solaris 2.5, almost all binary versions of `gcc' have old, unusable
  11665. include files that will break all programs that use threads, and
  11666. possibly other programs!
  11667.  
  11668. Solaris doesn't provide static versions of all system libraries
  11669. (`libpthreads' and `libdl'), so you can't compile MySQL with
  11670. `--static'.  If you try to do so, you will get one of the following
  11671. errors:
  11672.  
  11673.      ld: fatal: library -ldl: not found
  11674.      undefined reference to `dlopen'
  11675.      cannot find -lrt
  11676.  
  11677. If you link your own MySQL client programs, you may see the following
  11678. error at runtime:
  11679.  
  11680.      ld.so.1: fatal: libmysqlclient.so.#:
  11681.      open failed: No such file or directory
  11682.  
  11683. This problem can be avoided by one of the following methods:
  11684.  
  11685.    * Link clients with the `-Wl,r/full/path/to/libmysqlclient.so' flag
  11686.      rather than with `-Lpath').
  11687.  
  11688.    * Copy `libmysqclient.so' to `/usr/lib'.
  11689.  
  11690.    * Add the pathname of the directory where `libmysqlclient.so' is
  11691.      located to the `LD_RUN_PATH' environment variable before running
  11692.      your client.
  11693.  
  11694. If you have problems with `configure' trying to link with `-lz' when
  11695. you don't have `zlib' installed, you have two options:
  11696.  
  11697.    * If you want to be able to use the compressed communication
  11698.      protocol, you need to get and install `zlib' from `ftp.gnu.org'.
  11699.  
  11700.    * Run `configure' with the `--with-named-z-libs=no' option when
  11701.      building MySQL.
  11702.  
  11703. If you are using `gcc' and have problems with loading user-defined
  11704. functions (UDFs) into MySQL, try adding `-lgcc' to the link line for
  11705. the UDF.
  11706.  
  11707. If you would like MySQL to start automatically, you can copy
  11708. `support-files/mysql.server' to `/etc/init.d' and create a symbolic
  11709. link to it named `/etc/rc3.d/S99mysql.server'.
  11710.  
  11711. If too many processes try to connect very rapidly to `mysqld', you will
  11712. see this error in the MySQL log:
  11713.  
  11714.      Error in accept: Protocol error
  11715.  
  11716. You might try starting the server with the `--back_log=50' option as a
  11717. workaround for this.  (Use `-O back_log=50' before MySQL 4.)
  11718.  
  11719. Solaris doesn't support core files for `setuid()' applications, so you
  11720. can't get a core file from `mysqld' if you are using the `--user'
  11721. option.
  11722.  
  11723. Solaris 2.7/2.8 Notes
  11724. .....................
  11725.  
  11726. Normally, you can use a Solaris 2.6 binary on Solaris 2.7 and 2.8.  Most
  11727. of the Solaris 2.6 issues also apply for Solaris 2.7 and 2.8.
  11728.  
  11729. MySQL 3.23.4 and above should be able to detect new versions of Solaris
  11730. automatically and enable workarounds for the following problems.
  11731.  
  11732. Solaris 2.7 / 2.8 has some bugs in the include files.  You may see the
  11733. following error when you use `gcc':
  11734.  
  11735.      /usr/include/widec.h:42: warning: `getwc' redefined
  11736.      /usr/include/wchar.h:326: warning: this is the location of the previous
  11737.      definition
  11738.  
  11739. If this occurs, you can fix the problem by copying
  11740. `/usr/include/widec.h' to `.../lib/gcc-lib/os/gcc-version/include' and
  11741. changing line 41 from this:
  11742.  
  11743.      #if     !defined(lint) && !defined(__lint)
  11744.  
  11745. To this:
  11746.  
  11747.      #if     !defined(lint) && !defined(__lint) && !defined(getwc)
  11748.  
  11749. Alternatively, you can edit `/usr/include/widec.h' directly.  Either
  11750. way, after you make the fix, you should remove `config.cache' and run
  11751. `configure' again.
  11752.  
  11753. If you get the following errors when you run `make', it's because
  11754. `configure' didn't detect the `curses.h' file (probably because of the
  11755. error in `/usr/include/widec.h'):
  11756.  
  11757.      In file included from mysql.cc:50:
  11758.      /usr/include/term.h:1060: syntax error before `,'
  11759.      /usr/include/term.h:1081: syntax error before `;'
  11760.  
  11761. The solution to this problem is to do one of the following:
  11762.  
  11763.    * Configure with `CFLAGS=-DHAVE_CURSES_H CXXFLAGS=-DHAVE_CURSES_H
  11764.      ./configure'.
  11765.  
  11766.    * Edit `/usr/include/widec.h' as indicated in the preceding
  11767.      discussion and re-run `configure'.
  11768.  
  11769.    * Remove the `#define HAVE_TERM' line from the `config.h' file and
  11770.      run `make' again.
  11771.  
  11772. If your linker can't find `-lz' when linking client programs, the
  11773. problem is probably that your `libz.so' file is installed in
  11774. `/usr/local/lib'.  You can fix this problem by one of the following
  11775. methods:
  11776.  
  11777.    * Add `/usr/local/lib' to `LD_LIBRARY_PATH'.
  11778.  
  11779.    * Add a link to `libz.so' from `/lib'.
  11780.  
  11781.    * If you are using Solaris 8, you can install the optional `zlib'
  11782.      from your Solaris 8 CD distribution.
  11783.  
  11784.    * Run `configure' with the `--with-named-z-libs=no' option when
  11785.      building MySQL.
  11786.  
  11787. Solaris x86 Notes
  11788. .................
  11789.  
  11790. On Solaris 8 on x86, `mysqld' will dump core if you remove the debug
  11791. symbols using `strip'.
  11792.  
  11793. If you are using `gcc' or `egcs' on Solaris x86 and you experience
  11794. problems with core dumps under load, you should use the following
  11795. `configure' command:
  11796.  
  11797.      CC=gcc CFLAGS="-O3 -fomit-frame-pointer -DHAVE_CURSES_H" \
  11798.      CXX=gcc \
  11799.      CXXFLAGS="-O3 -fomit-frame-pointer -felide-constructors \
  11800.          -fno-exceptions -fno-rtti -DHAVE_CURSES_H" \
  11801.      ./configure --prefix=/usr/local/mysql
  11802.  
  11803. This will avoid problems with the `libstdc++' library and with C++
  11804. exceptions.
  11805.  
  11806. If this doesn't help, you should compile a debug version and run it
  11807. with a trace file or under `gdb'.  *Note Using `gdb' on `mysqld': Using
  11808. gdb on mysqld.
  11809.  
  11810. BSD Notes
  11811. ---------
  11812.  
  11813. This section provides information about using MySQL on variants of BSD
  11814. Unix.
  11815.  
  11816. FreeBSD Notes
  11817. .............
  11818.  
  11819. FreeBSD 4.x or newer is recommended for running MySQL, because the
  11820. thread package is much more integrated.  To get a secure and stable
  11821. system, you should use only FreeBSD kernels that are marked `-RELEASE'.
  11822.  
  11823. The easiest (and preferred) way to install MySQL is to use the
  11824. `mysql-server' and `mysql-client' ports available at
  11825. `http://www.freebsd.org/'.  Using these ports gives you the following
  11826. benefits:
  11827.  
  11828.    * A working MySQL with all optimizations enabled that are known to
  11829.      work on your version of FreeBSD.
  11830.  
  11831.    * Automatic configuration and build.
  11832.  
  11833.    * Startup scripts installed in `/usr/local/etc/rc.d'.
  11834.  
  11835.    * The ability to use `pkg_info -L' to see which files are installed.
  11836.  
  11837.    * The ability to use `pkg_delete' to remove MySQL if you no longer
  11838.      want it on your machine.
  11839.  
  11840. It is recommended you use MIT-pthreads on FreeBSD 2.x, and native
  11841. threads on Versions 3 and up. It is possible to run with native threads
  11842. on some late 2.2.x versions, but you may encounter problems shutting
  11843. down `mysqld'.
  11844.  
  11845. Unfortunately, certain function calls on FreeBSD are not yet fully
  11846. thread-safe.  Most notably, this includes the `gethostbyname()'
  11847. function, which is used by MySQL to convert hostnames into IP
  11848. addresses. Under certain circumstances, the `mysqld' process will
  11849. suddenly cause 100% CPU load and will be unresponsive. If you encounter
  11850. this problem, try to start MySQL using the `--skip-name-resolve' option.
  11851.  
  11852. Alternatively, you can link MySQL on FreeBSD 4.x against the
  11853. LinuxThreads library, which avoids a few of the problems that the
  11854. native FreeBSD thread implementation has. For a very good comparison of
  11855. LinuxThreads versus native threads, see Jeremy Zawodny's article
  11856. `FreeBSD or Linux for your MySQL Server?' at
  11857. `http://jeremy.zawodny.com/blog/archives/000697.html'.
  11858.  
  11859. A known problem when using LinuxThreads on FreeBSD is that the
  11860. `wait_timeout' value is not honored (probably a signal handling problem
  11861. in FreeBSD/LinuxThreads).  This is supposed to be fixed in FreeBSD 5.0.
  11862. The symptom is that persistent connections can hang for a very long
  11863. time without getting closed down.
  11864.  
  11865. The MySQL build process requires GNU make (`gmake') to work.  If GNU
  11866. `make' is not available, you must install it first before compiling
  11867. MySQL.
  11868.  
  11869. The recommended way to compile and install MySQL on FreeBSD with `gcc'
  11870. (2.95.2 and up) is:
  11871.  
  11872.      CC=gcc CFLAGS="-O2 -fno-strength-reduce" \
  11873.          CXX=gcc CXXFLAGS="-O2 -fno-rtti -fno-exceptions \
  11874.          -felide-constructors -fno-strength-reduce" \
  11875.          ./configure --prefix=/usr/local/mysql --enable-assembler
  11876.      gmake
  11877.      gmake install
  11878.      cd /usr/local/mysql
  11879.      bin/mysql_install_db --user=mysql
  11880.      bin/mysqld_safe &
  11881.  
  11882. If you notice that `configure' will use MIT-pthreads, you should read
  11883. the MIT-pthreads notes.  *Note MIT-pthreads::.
  11884.  
  11885. If you get an error from `make install' that it can't find
  11886. `/usr/include/pthreads', `configure' didn't detect that you need
  11887. MIT-pthreads. To fix this problem, remove `config.cache', then re-run
  11888. `configure' with the `--with-mit-threads' option.
  11889.  
  11890. Be sure that your name resolver setup is correct.  Otherwise, you may
  11891. experience resolver delays or failures when connecting to `mysqld'.
  11892. Also make sure that the `localhost' entry in the `/etc/hosts' file is
  11893. correct.  The file should start with a line similar to this:
  11894.  
  11895.      127.0.0.1       localhost localhost.your.domain
  11896.  
  11897. FreeBSD is known to have a very low default file handle limit.  *Note
  11898. Not enough file handles::.  Start the server by using the
  11899. `--open-files-limit' option for `mysqld_safe', or raise the limits for
  11900. the `mysqld' user in `/etc/login.conf' and rebuild it with `cap_mkdb
  11901. /etc/login.conf'.  Also be sure that you set the appropriate class for
  11902. this user in the password file if you are not using the default (use
  11903. `chpass mysqld-user-name').  *Note `mysqld_safe': mysqld_safe.
  11904.  
  11905. If you have a lot of memory, you should consider rebuilding the kernel
  11906. to allow MySQL to use more than 512MB of RAM.  Take a look at `option
  11907. MAXDSIZ' in the LINT config file for more information.
  11908.  
  11909. If you get problems with the current date in MySQL, setting the `TZ'
  11910. variable will probably help.  *Note Environment variables::.
  11911.  
  11912. NetBSD Notes
  11913. ............
  11914.  
  11915. To compile on NetBSD, you need GNU `make'. Otherwise, the build process
  11916. will fail when `make' tries to run `lint' on C++ files.
  11917.  
  11918. OpenBSD 2.5 Notes
  11919. .................
  11920.  
  11921. On OpenBSD Version 2.5, you can compile MySQL with native threads with
  11922. the following options:
  11923.  
  11924.      CFLAGS=-pthread CXXFLAGS=-pthread ./configure --with-mit-threads=no
  11925.  
  11926. OpenBSD 2.8 Notes
  11927. .................
  11928.  
  11929. Our users have reported that OpenBSD 2.8 has a threading bug that causes
  11930. problems with MySQL.  The OpenBSD Developers have fixed the problem,
  11931. but as of January 25, 2001, it's only available in the "-current"
  11932. branch.  The symptoms of this threading bug are slow response, high
  11933. load, high CPU usage, and crashes.
  11934.  
  11935. If you get an error like `Error in accept:: Bad file descriptor' or
  11936. error 9 when trying to open tables or directories, the problem is
  11937. probably that you have not allocated enough file descriptors for MySQL.
  11938.  
  11939. In this case, try starting `mysqld_safe' as `root' with the following
  11940. options:
  11941.  
  11942.      mysqld_safe --user=mysql --open-files-limit=2048 &
  11943.  
  11944. BSD/OS Version 2.x Notes
  11945. ........................
  11946.  
  11947. If you get the following error when compiling MySQL, your `ulimit'
  11948. value for virtual memory is too low:
  11949.  
  11950.      item_func.h: In method
  11951.      `Item_func_ge::Item_func_ge(const Item_func_ge &)':
  11952.      item_func.h:28: virtual memory exhausted
  11953.      make[2]: *** [item_func.o] Error 1
  11954.  
  11955. Try using `ulimit -v 80000' and run `make' again.  If this doesn't work
  11956. and you are using `bash', try switching to `csh' or `sh'; some BSDI
  11957. users have reported problems with `bash' and `ulimit'.
  11958.  
  11959. If you are using `gcc', you may also use have to use the
  11960. `--with-low-memory' flag for `configure' to be able to compile
  11961. `sql_yacc.cc'.
  11962.  
  11963. If you get problems with the current date in MySQL, setting the `TZ'
  11964. variable will probably help.  *Note Environment variables::.
  11965.  
  11966. BSD/OS Version 3.x Notes
  11967. ........................
  11968.  
  11969. Upgrade to BSD/OS Version 3.1.  If that is not possible, install
  11970. BSDIpatch M300-038.
  11971.  
  11972. Use the following command when configuring MySQL:
  11973.  
  11974.      env CXX=shlicc++ CC=shlicc2 \
  11975.      ./configure \
  11976.          --prefix=/usr/local/mysql \
  11977.          --localstatedir=/var/mysql \
  11978.          --without-perl \
  11979.          --with-unix-socket-path=/var/mysql/mysql.sock
  11980.  
  11981. The following is also known to work:
  11982.  
  11983.      env CC=gcc CXX=gcc CXXFLAGS=-O3 \
  11984.      ./configure \
  11985.          --prefix=/usr/local/mysql \
  11986.          --with-unix-socket-path=/var/mysql/mysql.sock
  11987.  
  11988. You can change the directory locations if you wish, or just use the
  11989. defaults by not specifying any locations.
  11990.  
  11991. If you have problems with performance under heavy load, try using the
  11992. `--skip-thread-priority' option to `mysqld'!  This will run all threads
  11993. with the same priority. On BSDI Version 3.1, this gives better
  11994. performance, at least until BSDI fixes its thread scheduler.
  11995.  
  11996. If you get the error `virtual memory exhausted' while compiling, you
  11997. should try using `ulimit -v 80000' and running `make' again.  If this
  11998. doesn't work and you are using `bash', try switching to `csh' or `sh';
  11999. some BSDI users have reported problems with `bash' and `ulimit'.
  12000.  
  12001. BSD/OS Version 4.x Notes
  12002. ........................
  12003.  
  12004. BSDI Version 4.x has some thread-related bugs.  If you want to use
  12005. MySQL on this, you should install all thread-related patches.  At least
  12006. M400-023 should be installed.
  12007.  
  12008. On some BSDI Version 4.x systems, you may get problems with shared
  12009. libraries.  The symptom is that you can't execute any client programs,
  12010. for example, `mysqladmin'.  In this case, you need to reconfigure not
  12011. to use shared libraries with the `--disable-shared' option to configure.
  12012.  
  12013. Some customers have had problems on BSDI 4.0.1 that the `mysqld' binary
  12014. after a while can't open tables.  This is because some
  12015. library/system-related bug causes `mysqld' to change current directory
  12016. without having asked for that to happen.
  12017.  
  12018. The fix is to either upgrade MySQL to at least version 3.23.34 or, after
  12019. running `configure', remove the line `#define HAVE_REALPATH' from
  12020. `config.h' before running `make'.
  12021.  
  12022. Note that this means that you can't symbolically link a database
  12023. directories to another database directory or symbolic link a table to
  12024. another database on BSDI.  (Making a symbolic link to another disk is
  12025. okay).
  12026.  
  12027. Other Unix Notes
  12028. ----------------
  12029.  
  12030. HP-UX Version 10.20 Notes
  12031. .........................
  12032.  
  12033. There are a couple of small problems when compiling MySQL on HP-UX.  We
  12034. recommend that you use `gcc' instead of the HP-UX native compiler,
  12035. because `gcc' produces better code.
  12036.  
  12037. We recommend using `gcc' 2.95 on HP-UX.  Don't use high optimization
  12038. flags (such as `-O6') because they may not be safe on HP-UX.
  12039.  
  12040. The following `configure' line should work with `gcc' 2.95:
  12041.  
  12042.      CFLAGS="-I/opt/dce/include -fpic" \
  12043.      CXXFLAGS="-I/opt/dce/include -felide-constructors -fno-exceptions \
  12044.      -fno-rtti" \
  12045.      CXX=gcc \
  12046.      ./configure --with-pthread \
  12047.          --with-named-thread-libs='-ldce' \
  12048.          --prefix=/usr/local/mysql --disable-shared
  12049.  
  12050. The following `configure' line should work with `gcc' 3.1:
  12051.  
  12052.      CFLAGS="-DHPUX -I/opt/dce/include -O3 -fPIC" CXX=gcc \
  12053.      CXXFLAGS="-DHPUX -I/opt/dce/include -felide-constructors \
  12054.          -fno-exceptions -fno-rtti -O3 -fPIC" \
  12055.      ./configure --prefix=/usr/local/mysql \
  12056.          --with-extra-charsets=complex --enable-thread-safe-client \
  12057.          --enable-local-infile  --with-pthread \
  12058.          --with-named-thread-libs=-ldce --with-lib-ccflags=-fPIC
  12059.          --disable-shared
  12060.  
  12061. HP-UX Version 11.x Notes
  12062. ........................
  12063.  
  12064. For HP-UX Version 11.x, we recommend MySQL 3.23.15 or later.
  12065.  
  12066. Because of some critical bugs in the standard HP-UX libraries, you
  12067. should install the following patches before trying to run MySQL on
  12068. HP-UX 11.0:
  12069.  
  12070.      PHKL_22840 Streams cumulative
  12071.      PHNE_22397 ARPA cumulative
  12072.  
  12073. This will solve the problem of getting `EWOULDBLOCK' from `recv()' and
  12074. `EBADF' from `accept()' in threaded applications.
  12075.  
  12076. If you are using `gcc' 2.95.1 on an unpatched HP-UX 11.x system, you
  12077. will get the error:
  12078.  
  12079.      In file included from /usr/include/unistd.h:11,
  12080.                       from ../include/global.h:125,
  12081.                       from mysql_priv.h:15,
  12082.                       from item.cc:19:
  12083.      /usr/include/sys/unistd.h:184: declaration of C function ...
  12084.      /usr/include/sys/pthread.h:440: previous declaration ...
  12085.      In file included from item.h:306,
  12086.                       from mysql_priv.h:158,
  12087.                       from item.cc:19:
  12088.  
  12089. The problem is that HP-UX doesn't define `pthreads_atfork()'
  12090. consistently.  It has conflicting prototypes in
  12091. `/usr/include/sys/unistd.h':184 and `/usr/include/sys/pthread.h':440.
  12092.  
  12093. One solution is to copy `/usr/include/sys/unistd.h' into
  12094. `mysql/include' and edit `unistd.h' and change it to match the
  12095. definition in `pthread.h'.  Look for this line:
  12096.  
  12097.      extern int pthread_atfork(void (*prepare)(), void (*parent)(),
  12098.                                                void (*child)());
  12099.  
  12100. Change it to look like this:
  12101.  
  12102.      extern int pthread_atfork(void (*prepare)(void), void (*parent)(void),
  12103.                                                void (*child)(void));
  12104.  
  12105. After making the change, the following `configure' line should work:
  12106.  
  12107.      CFLAGS="-fomit-frame-pointer -O3 -fpic" CXX=gcc \
  12108.      CXXFLAGS="-felide-constructors -fno-exceptions -fno-rtti -O3" \
  12109.      ./configure --prefix=/usr/local/mysql --disable-shared
  12110.  
  12111. If you are using MySQL 4.0.5 with the HP-UX compiler, you can use the
  12112. following command (which has been tested with `cc' B.11.11.04):
  12113.  
  12114.      CC=cc CXX=aCC CFLAGS=+DD64 CXXFLAGS=+DD64 ./configure \
  12115.          --with-extra-character-set=complex
  12116.  
  12117. You can ignore any errors of the following type:
  12118.  
  12119.      aCC: warning 901: unknown option: `-3': use +help for online
  12120.      documentation
  12121.  
  12122. If you get the following error from `configure', verify that you don't
  12123. have the path to the K&R compiler before the path to the HP-UX C and
  12124. C++ compiler:
  12125.  
  12126.      checking for cc option to accept ANSI C... no
  12127.      configure: error: MySQL requires an ANSI C compiler (and a C++ compiler).
  12128.      Try gcc. See the Installation chapter in the Reference Manual.
  12129.  
  12130. Another reason for not being able to compile is that you didn't define
  12131. the `+DD64' flags as just described.
  12132.  
  12133. Another possibility for HP-UX 11 is to use MySQL binaries for HP-UX
  12134. 10.20.  We have received reports from some users that these binaries
  12135. work fine on HP-UX 11.00. If you encounter problems, be sure to check
  12136. your HP-UX patch level.
  12137.  
  12138. IBM-AIX notes
  12139. .............
  12140.  
  12141. Automatic detection of `xlC' is missing from Autoconf, so a number of
  12142. variables need to be set before running `configure'. The following
  12143. example uses the IBM compiler:
  12144.  
  12145.      export CC="xlc_r -ma -O3 -qstrict -qoptimize=3 -qmaxmem=8192 "
  12146.      export CXX="xlC_r -ma -O3 -qstrict -qoptimize=3 -qmaxmem=8192"
  12147.      export CFLAGS="-I /usr/local/include"
  12148.      export LDFLAGS="-L /usr/local/lib"
  12149.      export CPPFLAGS=$CFLAGS
  12150.      export CXXFLAGS=$CFLAGS
  12151.      
  12152.      ./configure --prefix=/usr/local \
  12153.                      --localstatedir=/var/mysql \
  12154.                      --sbindir='/usr/local/bin' \
  12155.                      --libexecdir='/usr/local/bin' \
  12156.                      --enable-thread-safe-client \
  12157.                      --enable-large-files
  12158.  
  12159. The preceding options are used to compile the MySQL distribution that
  12160. can be found at `http://www-frec.bull.com/'.
  12161.  
  12162. If you change the `-O3' to `-O2' in the preceding `configure' line, you
  12163. must also remove the `-qstrict' option. This is a limitation in the IBM
  12164. C compiler.
  12165.  
  12166. If you are using `gcc' or `egcs' to compile MySQL, you _must_ use the
  12167. `-fno-exceptions' flag, because the exception handling in `gcc'/`egcs'
  12168. is not thread-safe!  (This is tested with `egcs' 1.1.)  There are also
  12169. some known problems with IBM's assembler that may cause it to generate
  12170. bad code when used with `gcc'.
  12171.  
  12172. We recommend the following `configure' line with `egcs' and `gcc' 2.95
  12173. on AIX:
  12174.  
  12175.      CC="gcc -pipe -mcpu=power -Wa,-many" \
  12176.      CXX="gcc -pipe -mcpu=power -Wa,-many" \
  12177.      CXXFLAGS="-felide-constructors -fno-exceptions -fno-rtti" \
  12178.      ./configure --prefix=/usr/local/mysql --with-low-memory
  12179.  
  12180. The `-Wa,-many' option is necessary for the compile to be successful.
  12181. IBM is aware of this problem but is in no hurry to fix it because of the
  12182. workaround that is available.  We don't know if the `-fno-exceptions'
  12183. is required with `gcc' 2.95, but because MySQL doesn't use exceptions
  12184. and the option generates faster code, we recommend that you should
  12185. always use it with `egcs' / `gcc'.
  12186.  
  12187. If you get a problem with assembler code, try changing the `-mcpu=XXX'
  12188. option to match your CPU. Typically `power2', `power', or `powerpc' may
  12189. need to be used.  Alternatively, you might need to use `604' or `604e'.
  12190. We are not positive but suspect that `power' would likely be safe most
  12191. of the time, even on a power2 machine.
  12192.  
  12193. If you don't know what your CPU is, execute a `uname -m' command.  It
  12194. will produce a string that looks like `000514676700', with a format of
  12195. `xxyyyyyymmss' where `xx' and `ss' are always `00', `yyyyyy' is a
  12196. unique system ID and `mm' is the ID of the CPU Planar.  A chart of
  12197. these values can be found at
  12198. `http://publib.boulder.ibm.com/doc_link/en_US/a_doc_lib/cmds/aixcmds5/uname.htm'.
  12199. This will give you a machine type and a machine model you can use to
  12200. determine what type of CPU you have.
  12201.  
  12202. If you have problems with signals (MySQL dies unexpectedly under high
  12203. load), you may have found an OS bug with threads and signals.  In this
  12204. case, you can tell MySQL not to use signals by configuring as follows:
  12205.  
  12206.      CFLAGS=-DDONT_USE_THR_ALARM CXX=gcc \
  12207.      CXXFLAGS="-felide-constructors -fno-exceptions -fno-rtti \
  12208.      -DDONT_USE_THR_ALARM" \
  12209.      ./configure --prefix=/usr/local/mysql --with-debug \
  12210.          --with-low-memory
  12211.  
  12212. This doesn't affect the performance of MySQL, but has the side effect
  12213. that you can't kill clients that are "sleeping" on a connection with
  12214. `mysqladmin kill' or `mysqladmin shutdown'.  Instead, the client will
  12215. die when it issues its next command.
  12216.  
  12217. On some versions of AIX, linking with `libbind.a' makes
  12218. `getservbyname()' dump core.  This is an AIX bug and should be reported
  12219. to IBM.
  12220.  
  12221. For AIX 4.2.1 and `gcc', you have to make the following changes.
  12222.  
  12223. After configuring, edit `config.h' and `include/my_config.h' and change
  12224. the line that says this:
  12225.  
  12226.      #define HAVE_SNPRINTF 1
  12227.  
  12228. to this:
  12229.  
  12230.      #undef HAVE_SNPRINTF
  12231.  
  12232. And finally, in `mysqld.cc', you need to add a prototype for
  12233. `initgroups()'.
  12234.  
  12235.      #ifdef _AIX41
  12236.      extern "C" int initgroups(const char *,int);
  12237.      #endif
  12238.  
  12239. If you need to allocate a lot of memory to the `mysqld' process, it's
  12240. not enough to just use `ulimit -d unlimited'. You may also have to
  12241. modify `mysqld_safe' to add a line something like this:
  12242.  
  12243.      export LDR_CNTRL='MAXDATA=0x80000000'
  12244.  
  12245. You can find more information about using a lot of memory at
  12246. `http://publib16.boulder.ibm.com/pseries/en_US/aixprggd/genprogc/lrg_prg_support.htm'.
  12247.  
  12248. SunOS 4 Notes
  12249. .............
  12250.  
  12251. On SunOS 4, MIT-pthreads is needed to compile MySQL. This in turn means
  12252. you will need GNU `make'.
  12253.  
  12254. Some SunOS 4 systems have problems with dynamic libraries and `libtool'.
  12255. You can use the following `configure' line to avoid this problem:
  12256.  
  12257.      ./configure --disable-shared --with-mysqld-ldflags=-all-static
  12258.  
  12259. When compiling `readline', you may get warnings about duplicate defines.
  12260. These can be ignored.
  12261.  
  12262. When compiling `mysqld', there will be some `implicit declaration of
  12263. function' warnings. These can be ignored.
  12264.  
  12265. Alpha-DEC-UNIX Notes (Tru64)
  12266. ............................
  12267.  
  12268. If you are using `egcs' 1.1.2 on Digital Unix, you should upgrade to
  12269. `gcc' 2.95.2, because `egcs' on DEC has some serious bugs!
  12270.  
  12271. When compiling threaded programs under Digital Unix, the documentation
  12272. recommends using the `-pthread' option for `cc' and `cxx' and the
  12273. `-lmach -lexc' libraries (in addition to `-lpthread').  You should run
  12274. `configure' something like this:
  12275.  
  12276.      CC="cc -pthread" CXX="cxx -pthread -O" \
  12277.      ./configure --with-named-thread-libs="-lpthread -lmach -lexc -lc"
  12278.  
  12279. When compiling `mysqld', you may see a couple of warnings like this:
  12280.  
  12281.      mysqld.cc: In function void handle_connections()':
  12282.      mysqld.cc:626: passing long unsigned int *' as argument 3 of
  12283.      accept(int,sockadddr *, int *)'
  12284.  
  12285. You can safely ignore these warnings.  They occur because `configure'
  12286. can detect only errors, not warnings.
  12287.  
  12288. If you start the server directly from the command line, you may have
  12289. problems with it dying when you log out.  (When you log out, your
  12290. outstanding processes receive a `SIGHUP' signal.)  If so, try starting
  12291. the server like this:
  12292.  
  12293.      nohup mysqld [OPTIONS] &
  12294.  
  12295. `nohup' causes the command following it to ignore any `SIGHUP' signal
  12296. sent from the terminal.  Alternatively, start the server by running
  12297. `mysqld_safe', which invokes `mysqld' using `nohup' for you.  *Note
  12298. `mysqld_safe': mysqld_safe.
  12299.  
  12300. If you get a problem when compiling `mysys/get_opt.c', just remove the
  12301. `#define _NO_PROTO' line from the start of that file.
  12302.  
  12303. If you are using Compaq's CC compiler, the following `configure' line
  12304. should work:
  12305.  
  12306.      CC="cc -pthread"
  12307.      CFLAGS="-O4 -ansi_alias -ansi_args -fast -inline speed all -arch host"
  12308.      CXX="cxx -pthread"
  12309.      CXXFLAGS="-O4 -ansi_alias -ansi_args -fast -inline speed all \
  12310.          -arch host -noexceptions -nortti"
  12311.      export CC CFLAGS CXX CXXFLAGS
  12312.      ./configure \
  12313.          --prefix=/usr/local/mysql \
  12314.          --with-low-memory \
  12315.          --enable-large-files \
  12316.          --enable-shared=yes \
  12317.          --with-named-thread-libs="-lpthread -lmach -lexc -lc"
  12318.      gnumake
  12319.  
  12320. If you get a problem with `libtool' when compiling with shared libraries
  12321. as just shown, when linking `mysql', you should be able to get around
  12322. this by issuing these commands:
  12323.  
  12324.      cd mysql
  12325.      /bin/sh ../libtool --mode=link cxx -pthread  -O3 -DDBUG_OFF \
  12326.          -O4 -ansi_alias -ansi_args -fast -inline speed \
  12327.          -speculate all \ -arch host  -DUNDEF_HAVE_GETHOSTBYNAME_R \
  12328.          -o mysql  mysql.o readline.o sql_string.o completion_hash.o \
  12329.          ../readline/libreadline.a -lcurses \
  12330.          ../libmysql/.libs/libmysqlclient.so  -lm
  12331.      cd ..
  12332.      gnumake
  12333.      gnumake install
  12334.      scripts/mysql_install_db
  12335.  
  12336. Alpha-DEC-OSF/1 Notes
  12337. .....................
  12338.  
  12339. If you have problems compiling and have DEC `CC' and `gcc' installed,
  12340. try running `configure' like this:
  12341.  
  12342.      CC=cc CFLAGS=-O CXX=gcc CXXFLAGS=-O3 \
  12343.      ./configure --prefix=/usr/local/mysql
  12344.  
  12345. If you get problems with the `c_asm.h' file, you can create and use a
  12346. 'dummy' `c_asm.h' file with:
  12347.  
  12348.      touch include/c_asm.h
  12349.      CC=gcc CFLAGS=-I./include \
  12350.      CXX=gcc CXXFLAGS=-O3 \
  12351.      ./configure --prefix=/usr/local/mysql
  12352.  
  12353. Note that the following problems with the `ld' program can be fixed by
  12354. downloading the latest DEC (Compaq) patch kit from:
  12355. `http://ftp.support.compaq.com/public/unix/'.
  12356.  
  12357. On OSF/1 V4.0D and compiler "DEC C V5.6-071 on Digital Unix V4.0 (Rev.
  12358. 878)," the compiler had some strange behavior (undefined `asm' symbols).
  12359. `/bin/ld' also appears to be broken (problems with `_exit undefined'
  12360. errors occurring while linking `mysqld').  On this system, we have
  12361. managed to compile MySQL with the following `configure' line, after
  12362. replacing `/bin/ld' with the version from OSF 4.0C:
  12363.  
  12364.      CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql
  12365.  
  12366. With the Digital compiler "C++ V6.1-029," the following should work:
  12367.  
  12368.      CC=cc -pthread
  12369.      CFLAGS=-O4 -ansi_alias -ansi_args -fast -inline speed \
  12370.             -speculate all -arch host
  12371.      CXX=cxx -pthread
  12372.      CXXFLAGS=-O4 -ansi_alias -ansi_args -fast -inline speed \
  12373.               -speculate all -arch host -noexceptions -nortti
  12374.      export CC CFLAGS CXX CXXFLAGS
  12375.      ./configure --prefix=/usr/mysql/mysql \
  12376.                  --with-mysqld-ldflags=-all-static --disable-shared \
  12377.                  --with-named-thread-libs="-lmach -lexc -lc"
  12378.  
  12379. In some versions of OSF/1, the `alloca()' function is broken. Fix this
  12380. by removing the line in `config.h' that defines `'HAVE_ALLOCA''.
  12381.  
  12382. The `alloca()' function also may have an incorrect prototype in
  12383. `/usr/include/alloca.h'.  This warning resulting from this can be
  12384. ignored.
  12385.  
  12386. `configure' will use the following thread libraries automatically:
  12387. `--with-named-thread-libs="-lpthread -lmach -lexc -lc"'.
  12388.  
  12389. When using `gcc', you can also try running `configure' like this:
  12390.  
  12391.      CFLAGS=-D_PTHREAD_USE_D4 CXX=gcc CXXFLAGS=-O3 ./configure ...
  12392.  
  12393. If you have problems with signals (MySQL dies unexpectedly under high
  12394. load), you may have found an OS bug with threads and signals. In this
  12395. case, you can tell MySQL not to use signals by configuring with:
  12396.  
  12397.      CFLAGS=-DDONT_USE_THR_ALARM \
  12398.      CXXFLAGS=-DDONT_USE_THR_ALARM \
  12399.      ./configure ...
  12400.  
  12401. This doesn't affect the performance of MySQL, but has the side effect
  12402. that you can't kill clients that are "sleeping" on a connection with
  12403. `mysqladmin kill' or `mysqladmin shutdown'.  Instead, the client will
  12404. die when it issues its next command.
  12405.  
  12406. With `gcc' 2.95.2, you will probably run into the following compile
  12407. error:
  12408.  
  12409.      sql_acl.cc:1456: Internal compiler error in `scan_region',
  12410.      at except.c:2566
  12411.      Please submit a full bug report.
  12412.  
  12413. To fix this, you should change to the `sql' directory and do a
  12414. cut-and-paste of the last `gcc' line, but change `-O3' to `-O0' (or add
  12415. `-O0' immediately after `gcc' if you don't have any `-O' option on your
  12416. compile line).  After this is done, you can just change back to the
  12417. top-level directory and run `make' again.
  12418.  
  12419. SGI Irix Notes
  12420. ..............
  12421.  
  12422. If you are using Irix Version 6.5.3 or newer, `mysqld' will be able to
  12423. create threads only if you run it as a user that has `CAP_SCHED_MGT'
  12424. privileges (such as `root') or give the `mysqld' server this privilege
  12425. with the following shell command:
  12426.  
  12427.      chcap "CAP_SCHED_MGT+epi" /opt/mysql/libexec/mysqld
  12428.  
  12429. You may have to undefine some symbols in `config.h' after running
  12430. `configure' and before compiling.
  12431.  
  12432. In some Irix implementations, the `alloca()' function is broken.  If the
  12433. `mysqld' server dies on some `SELECT' statements, remove the lines from
  12434. `config.h' that define `HAVE_ALLOC' and `HAVE_ALLOCA_H'.  If
  12435. `mysqladmin create' doesn't work, remove the line from `config.h' that
  12436. defines `HAVE_READDIR_R'.  You may have to remove the `HAVE_TERM_H'
  12437. line as well.
  12438.  
  12439. SGI recommends that you install all the patches on this page as a set:
  12440. `http://support.sgi.com/surfzone/patches/patchset/6.2_indigo.rps.html'
  12441.  
  12442. At the very minimum, you should install the latest kernel rollup, the
  12443. latest `rld' rollup, and the latest `libc' rollup.
  12444.  
  12445. You definitely need all the POSIX patches on this page, for pthreads
  12446. support:
  12447.  
  12448. `http://support.sgi.com/surfzone/patches/patchset/6.2_posix.rps.html'
  12449.  
  12450. If you get the something like the following error when compiling
  12451. `mysql.cc':
  12452.  
  12453.      "/usr/include/curses.h", line 82: error(1084):
  12454.      invalid combination of type
  12455.  
  12456. Type the following in the top-level directory of your MySQL source tree:
  12457.  
  12458.      extra/replace bool curses_bool < /usr/include/curses.h > include/curses.h
  12459.      make
  12460.  
  12461. There have also been reports of scheduling problems.  If only one
  12462. thread is running, performance is slow.  Avoid this by starting another
  12463. client.  This may lead to a two-to-tenfold increase in execution speed
  12464. thereafter for the other thread.  This is a poorly understood problem
  12465. with Irix threads; you may have to improvise to find solutions until
  12466. this can be fixed.
  12467.  
  12468. If you are compiling with `gcc', you can use the following `configure'
  12469. command:
  12470.  
  12471.      CC=gcc CXX=gcc CXXFLAGS=-O3 \
  12472.      ./configure --prefix=/usr/local/mysql --enable-thread-safe-client \
  12473.          --with-named-thread-libs=-lpthread
  12474.  
  12475. On Irix 6.5.11 with native Irix C and C++ compilers ver. 7.3.1.2, the
  12476. following is reported to work
  12477.  
  12478.      CC=cc CXX=CC CFLAGS='-O3 -n32 -TARG:platform=IP22 -I/usr/local/include \
  12479.      -L/usr/local/lib' CXXFLAGS='-O3 -n32 -TARG:platform=IP22 \
  12480.      -I/usr/local/include -L/usr/local/lib' \
  12481.      ./configure --prefix=/usr/local/mysql --with-innodb --with-berkeley-db \
  12482.          --with-libwrap=/usr/local \
  12483.          --with-named-curses-libs=/usr/local/lib/libncurses.a
  12484.  
  12485. SCO Notes
  12486. .........
  12487.  
  12488. The current port is tested only on "sco3.2v5.0.5," "sco3.2v5.0.6," and
  12489. "sco3.2v5.0.7" systems. There has also been a lot of progress on a port
  12490. to "sco 3.2v4.2."  Open Server 5.0.8(Legend) will have native threads
  12491. and allow files greater than 2GB.  The current maximum file size is 2GB.
  12492.  
  12493. We have been able to compile MySQL with the following `configure'
  12494. command on on OpenServer with `gcc' 2.95.3.
  12495.  
  12496.      CC=gcc CXX=gcc ./configure --prefix=/usr/local/mysql \
  12497.          --enable-thread-safe-client --with-innodb \
  12498.          --with-openssl --with-vio --with-extra-charsets=complex
  12499.  
  12500. `gcc' is available at
  12501. `ftp://ftp.sco.com/pub/openserver5/opensrc/gnutools-5.0.7Kj'.
  12502.  
  12503. This development system requires the OpenServer Execution Enviroment
  12504. Supplement oss646B on OpenServer 5.0.6 and oss656B and The OpenSource
  12505. libraries found in gwxlibs.  All OpenSource tools are in the `opensrc'
  12506. directory.  They are available at
  12507. `ftp://ftp.sco.com/pub/openserver5/opensrc/'.
  12508.  
  12509. We recommend using the latest production release of MySQL.  Currently
  12510. MySQL-4.0.x is the latest production release.  There were some problems
  12511. with MySQL 4.0.17 and MySQL 4.0.18, but they have now been fixed.
  12512.  
  12513. SCO provides operating system patches at
  12514. `ftp://ftp.sco.com/pub/openserver5' for OpenServer 5.0.[0-6] and
  12515. `ftp://ftp.sco.com/pub/openserverv5/507' for OpenServer 5.0.7.
  12516.  
  12517. SCO provides information about security fixes at
  12518. `ftp://ftp.sco.com/pub/security/OpenServer' for OpenServer 5.0.x.
  12519.  
  12520. The maximum file size on an OpenSever 5.0.x system is 2GB.
  12521.  
  12522. The total memory which could be allocated for streams buffers, clists
  12523. and lock records cannot exceed 60MB on OpenServer 5.0.x.
  12524.  
  12525. Streams buffers are allocated in units of 4096 byte pages, clists are 70
  12526. bytes each, and lock records are 64 bytes each, so:
  12527.  
  12528.      (NSTRPAGES * 4096) + (NCLIST * 70) + (MAX_FLCKREC * 64) <= 62914560
  12529.  
  12530. Follow this procedure to configure the Database Services option. If you
  12531. are unsure whether an application requires this, see the documentation
  12532. provided with the application.
  12533.  
  12534.   1. Log in as `root'.
  12535.  
  12536.   2. Enable the SUDS driver by editing the `/etc/conf/sdevice.d/suds'
  12537.      file.  Change the `N' in the second field to a `Y'.
  12538.  
  12539.   3. Use `mkdev aio' or the Hardware/Kernel Manager to enable support
  12540.      for asynchronous I/O and relink the kernel. To allow users to lock
  12541.      down memory for use with this type of I/O, update the
  12542.      aiomemlock(F) file. This file should be updated to include the
  12543.      names of users that can use AIO and the maximum amounts of memory
  12544.      they can lock down.
  12545.  
  12546.   4. Many applications use setuid binaries so that you need to specify
  12547.      only a single user. See the documentation provided with the
  12548.      application to see if this is the case for your application.
  12549.  
  12550. After you complete this process, reboot the system to create a new
  12551. kernel incorporating these changes.
  12552.  
  12553. By default, the entries in `/etc/conf/cf.d/mtune' are set as follows:
  12554.  
  12555.      Value           Default         Min             Max
  12556.      -----           -------         ---             ---
  12557.      NBUF            0               24              450000
  12558.      NHBUF           0               32              524288
  12559.      NMPBUF          0               12              512
  12560.      MAX_INODE       0               100             64000
  12561.      MAX_FILE        0               100             64000
  12562.      CTBUFSIZE       128             0               256
  12563.      MAX_PROC        0               50              16000
  12564.      MAX_REGION      0               500             160000
  12565.      NCLIST          170             120             16640
  12566.      MAXUP           100             15              16000
  12567.      NOFILES         110             60              11000
  12568.      NHINODE         128             64              8192
  12569.      NAUTOUP         10              0               60
  12570.      NGROUPS         8               0               128
  12571.      BDFLUSHR        30              1               300
  12572.      MAX_FLCKREC     0               50              16000
  12573.      PUTBUFSZ        8000            2000            20000
  12574.      MAXSLICE        100             25              100
  12575.      ULIMIT          4194303         2048            4194303
  12576.      * Streams Parameters
  12577.      NSTREAM         64              1               32768
  12578.      NSTRPUSH        9               9               9
  12579.      NMUXLINK        192             1               4096
  12580.      STRMSGSZ        16384           4096            524288
  12581.      STRCTLSZ        1024            1024            1024
  12582.      STRMAXBLK       524288          4096            524288
  12583.      NSTRPAGES       500             0               8000
  12584.      STRSPLITFRAC    80              50              100
  12585.      NLOG            3               3               3
  12586.      NUMSP           64              1               256
  12587.      NUMTIM          16              1               8192
  12588.      NUMTRW          16              1               8192
  12589.      * Semaphore Parameters
  12590.      SEMMAP          10              10              8192
  12591.      SEMMNI          10              10              8192
  12592.      SEMMNS          60              60              8192
  12593.      SEMMNU          30              10              8192
  12594.      SEMMSL          25              25              150
  12595.      SEMOPM          10              10              1024
  12596.      SEMUME          10              10              25
  12597.      SEMVMX          32767           32767           32767
  12598.      SEMAEM          16384           16384           16384
  12599.      * Shared Memory Parameters
  12600.      SHMMAX          524288          131072          2147483647
  12601.      SHMMIN          1               1               1
  12602.      SHMMNI          100             100             2000
  12603.      FILE            0               100             64000
  12604.      NMOUNT          0               4               256
  12605.      NPROC           0               50              16000
  12606.      NREGION         0               500             160000
  12607.  
  12608. We recommend setting these values as follows:
  12609.  
  12610. `NOFILES' should be 4096 or 2048.
  12611.  
  12612. `MAXUP' should be 2048.
  12613.  
  12614. To make changes to the kernel, `cd' to `/etc/conf/bin' and use
  12615. `./idtune' NAME PARAMETER to make the changes. For example, to change
  12616. `SEMMS' to `200', execute these commands as `root':
  12617.  
  12618.      # cd /etc/conf/bin
  12619.      # ./idtune SEMMNS 200
  12620.  
  12621. We recommend tuning the system, but the proper parameter values to use
  12622. depend on the number of users accessing the application or database and
  12623. size the of the database (that is, the used buffer pool). The following
  12624. will affect the following kernel parameters defined in
  12625. `/etc/conf/cf.d/stune':
  12626.  
  12627. `SHMMAX' (recommended setting: 128MB) and `SHMSEG' (recommended
  12628. setting: 15).  These parameters have influence on the MySQL database
  12629. engine to create user buffer pools.
  12630.  
  12631. `NOFILES' and `MAXUP' should be at to at least 2048.
  12632.  
  12633. `MAXPROC' should be set to at least 3000/4000 (depends on number of
  12634. users) or more.
  12635.  
  12636. Also is recommended to use following formula to count value for
  12637. `SEMMSL', `SEMMNS' and `SEMMNU':
  12638.  
  12639.      SEMMSL = 13
  12640.  
  12641. The 13 is what has been found to be the best for both Progress and
  12642. MySQL.
  12643.  
  12644. `SEMMNS' = `SEMMSL' * number of db servers to be run on the system.
  12645.  
  12646. Set `SEMMNS' to the value of `SEMMSL' multiplied by the number of db
  12647. servers (maximum) that you will be running on the system at one time.
  12648.  
  12649.      SEMMNU = SEMMNS
  12650.  
  12651. Set the value of `SEMMNU' to equal the value of `SEMMNS'. You could
  12652. probably set this to 75% of `SEMMNS', but this is a conservative
  12653. estimate.
  12654.  
  12655. You need to at least install the "SCO OpenServer Linker and Application
  12656. Development Libraries" or the OpenServer Development System to use
  12657. `gcc'.  You cannot just use the GCC Dev system without installing one
  12658. of these.
  12659.  
  12660. You should get the FSU Pthreads package and install it first. This can
  12661. be found at
  12662. `http://moss.csc.ncsu.edu/~mueller/ftp/pub/PART/pthreads.tar.gz'.  You
  12663. can also get a precompiled package from
  12664. `ftp://ftp.zenez.com/pub/zenez/prgms/FSU-threads-3.14.tar.gz'.
  12665.  
  12666. FSU Pthreads can be compiled with SCO Unix 4.2 with tcpip, or using
  12667. OpenServer 3.0 or Open Desktop 3.0 (OS 3.0 ODT 3.0) with the SCO
  12668. Development System installed using a good port of GCC 2.5.x. For ODT or
  12669. OS 3.0, you will need a good port of GCC 2.5.x. There are a lot of
  12670. problems without a good port. The port for this product requires the
  12671. SCO Unix Development system. Without it, you are missing the libraries
  12672. and the linker that is needed.  You will also need
  12673. `SCO-3.2v4.2-includes.tar.gz'. This file contains the changes to the
  12674. SCO Development include files that are needed to get MySQL to build.
  12675. You need to replace the existing system include files with these
  12676. modified header files.  They can be obtained from
  12677. `ftp://ftp.zenez.com/pub/zenez/prgms/SCO-3.2v4.2-includes.tar.gz'.
  12678.  
  12679. To build FSU Pthreads on your system, all you should need to do is run
  12680. GNU `make'.  The `Makefile' in FSU-threads-3.14.tar.gz is already set
  12681. up to make FSU-threads.
  12682.  
  12683. You can run `./configure' in the `threads/src' directory and select the
  12684. SCO OpenServer option. This command copies `Makefile.SCO5' to
  12685. `Makefile'.  Then run `make'.
  12686.  
  12687. To install in the default `/usr/include' directory, log in as `root',
  12688. then `cd' to the `thread/src' directory and run `make install'.
  12689.  
  12690. Remember that you must use GNU `make' when making MySQL.
  12691.  
  12692. *Note*: If you don't start `mysqld_safe' as `root', you probably will
  12693. get only the default 110 open files per process. `mysqld' will write a
  12694. note about this in the log file.
  12695.  
  12696. With SCO 3.2V4.2, you should use FSU Pthreads version 3.14 or newer.
  12697. The following `configure' command should work:
  12698.  
  12699.      CFLAGS="-D_XOPEN_XPG4" CXX=gcc CXXFLAGS="-D_XOPEN_XPG4" \
  12700.      ./configure \
  12701.          --prefix=/usr/local/mysql \
  12702.          --with-named-thread-libs="-lgthreads -lsocket -lgen -lgthreads" \
  12703.          --with-named-curses-libs="-lcurses"
  12704.  
  12705. You may get some problems with some include files. In this case, you can
  12706. find new SCO-specific include files at
  12707. `ftp://ftp.zenez.com/pub/zenez/prgms/SCO-3.2v4.2-includes.tar.gz'.
  12708.  
  12709. You should unpack this file in the `include' directory of your MySQL
  12710. source tree.
  12711.  
  12712. SCO development notes:
  12713.  
  12714.    bullet MySQL should automatically detect FSU Pthreads and link
  12715.      `mysqld' with `-lgthreads -lsocket -lgthreads'.
  12716.  
  12717.    bullet The SCO development libraries are re-entrant in FSU Pthreads.
  12718.      SCO claims that its library functions are re-entrant, so they must
  12719.      be re-entrant with FSU Pthreads. FSU Pthreads on OpenServer tries
  12720.      to use the SCO scheme to make re-entrant libraries.
  12721.  
  12722.    bullet FSU Pthreads (at least the version at `ftp::/ftp.zenez.com')
  12723.      comes linked with GNU `malloc'. If you encounter problems with
  12724.      memory usage, make sure that `gmalloc.o' is included in
  12725.      `libgthreads.a' and `libgthreads.so'.
  12726.  
  12727.    bullet In FSU Pthreads, the following system calls are
  12728.      pthreads-aware: `read()', `write()', `getmsg()', `connect()',
  12729.      `accept(),' `select()', and `wait()'.
  12730.  
  12731.    bullet The CSSA-2001-SCO.35.2 (the patch is listed in custom as
  12732.      erg711905-dscr_remap security patch (version 2.0.0)) breaks FSU
  12733.      threads and makes `mysqld' unstable. You have to remove this one
  12734.      if you want to run `mysqld' on an OpenServer 5.0.6 machine.
  12735.  
  12736.    bullet SCO provides operating system patches at
  12737.      `ftp://ftp.sco.com/pub/openserver5' for OpenServer 5.0.x.
  12738.  
  12739.    bullet SCO provides security fixes and `libsocket.so.2' at
  12740.      `ftp://ftp.sco.com/pub/security/OpenServer' and
  12741.      `ftp://ftp.sco.com/pub/security/sse' for OpenServer 5.0.x.
  12742.  
  12743.    bullet Pre-OSR506 security fixes. Also, the `telnetd' fix at
  12744.      `ftp://stage.caldera.com/pub/security/openserver/' or
  12745.      `ftp://stage.caldera.com/pub/security/openserver/CSSA-2001-SCO.10/'
  12746.      as both `libsocket.so.2' and `libresolv.so.1' with instructions for
  12747.      installing on pre-OSR506 systems.
  12748.  
  12749.      It's probably a good idea to install these patches before trying
  12750.      to compile/use MySQL.
  12751.  
  12752.  
  12753. Begining with Legend, OpenServer will have native threads and no 2GB
  12754. file size limit.
  12755.  
  12756. SCO UnixWare Version 7.1.x Notes
  12757. ................................
  12758.  
  12759. We recommend using the latest production release of MySQL.  Currently
  12760. this is MySQL 4.0.x.  Should you choose to use an older release of
  12761. MySQL on UnixWare 7.1.x, you must use a version of MySQL at least as
  12762. recent as 3.22.13 to get fixes for some portability and OS problems.
  12763.  
  12764. We have been able to compile MySQL with the following `configure'
  12765. command on UnixWare Version 7.1.x:
  12766.  
  12767.      CC="cc" CFLAGS="-I/usr/local/include" \
  12768.      CXX="CC" CXXFLAGS="-I/usr/local/include" \
  12769.      ./configure --prefix=/usr/local/mysql \
  12770.          --enable-thread-safe-client --with-berkeley-db=./bdb \
  12771.          --with-innodb --with-openssl --with-extra-charsets=complex
  12772.  
  12773. If you want to use `gcc', you must use `gcc' 2.95.3 or newer.
  12774.  
  12775.      CC=gcc CXX=g++ ./configure --prefix=/usr/local/mysql
  12776.  
  12777. SCO provides operating system patches at
  12778. `ftp://ftp.sco.com/pub/unixware7' for UnixWare 7.1.1,
  12779. `ftp://ftp.sco.com/pub/unixware7/713/' for UnixWare 7.1.3,
  12780. `ftp://ftp.sco.com/pub/unixware7/714/' for UnixWare 7.1.4, and
  12781. `ftp://ftp.sco.com/pub/openunix8' for OpenUNIX 8.0.0.
  12782.  
  12783. SCO provides information about security fixes at
  12784. `ftp://ftp.sco.com/pub/security/OpenUNIX' for OpenUNIX and
  12785. `ftp://ftp.sco.com/pub/security/UnixWare' for UnixWare.
  12786.  
  12787. By default, the maximum file size on a UnixWare 7 system is 1GB.  Many
  12788. OS utilities have a limitation of 2GB.  The maximum possible file size
  12789. on UnixWare 7 is 1TB with VXFS.
  12790.  
  12791. To enable large file support on UnixWare 7.1.x, run `fsadm'.
  12792.  
  12793.      # fsadm -Fvxfs -o largefiles /
  12794.      # fsadm /                    * Note
  12795.      # ulimit unlimited
  12796.      # cd /etc/conf/bin
  12797.      # ./idtune SFSZLIM 0x7FFFFFFF            ** Note
  12798.      # ./idtune HFSZLIM 0x7FFFFFFF            ** Note
  12799.      # ./idbuild -B
  12800.      
  12801.      * This should report "largefiles".
  12802.      ** 0x7FFFFFFF represents infinity for these values.
  12803.  
  12804. Reboot the system using `shutdown'.
  12805.  
  12806. By default, the entries in `/etc/conf/cf.d/mtune' are set to:
  12807.  
  12808.      Value           Default         Min             Max
  12809.      -----           -------         ---             ---
  12810.      SVMMLIM         0x9000000       0x1000000       0x7FFFFFFF
  12811.      HVMMLIM         0x9000000       0x1000000       0x7FFFFFFF
  12812.      SSTKLIM         0x1000000       0x2000          0x7FFFFFFF
  12813.      HSTKLIM         0x1000000       0x2000          0x7FFFFFFF
  12814.  
  12815. We recommend setting these values as follows:
  12816.  
  12817.      SDATLIM 0x7FFFFFFF
  12818.      HDATLIM 0x7FFFFFFF
  12819.      SSTKLIM 0x7FFFFFFF
  12820.      HSTKLIM 0x7FFFFFFF
  12821.      SVMMLIM 0x7FFFFFFF
  12822.      HVMMLIM 0x7FFFFFFF
  12823.      SFNOLIM 2048
  12824.      HFNOLIM 2048
  12825.  
  12826. We recommend tuning the system, but the proper parameter values to use
  12827. depend on the number of users accessing the application or database and
  12828. size the of the database (that is, the used buffer pool). The following
  12829. will affect the following kernel parameters defined in
  12830. `/etc/conf/cf.d/stune':
  12831.  
  12832. `SHMMAX' (recommended setting: 128MB) and `SHMSEG' (recommended
  12833. setting: 15).  These parameters have influence on the MySQL database
  12834. engine to create user buffer pools.
  12835.  
  12836. `SFNOLIM' and `HFNOLIM' should be at maximum 2048.
  12837.  
  12838. `NPROC' should be set to at least 3000/4000 (depends on number of
  12839. users).
  12840.  
  12841. Also is recommended to use following formula to count value for
  12842. `SEMMSL', `SEMMNS', and `SEMMNU':
  12843.  
  12844.      SEMMSL = 13
  12845.  
  12846. 13 is what has been found to be the best for both Progress and MySQL.
  12847.  
  12848. `SEMMNS' = `SEMMSL' * number of db servers to be run on the system.
  12849.  
  12850. Set `SEMMNS' to the value of `SEMMSL' multiplied by the number of db
  12851. servers (maximum) that you will be running on the system at one time.
  12852.  
  12853. `SEMMNU' = `SEMMNS'
  12854.  
  12855. Set the value of `SEMMNU' to equal the value of `SEMMNS'. You could
  12856. probably set this to 75% of `SEMMNS', but this is a conservative
  12857. estimate.
  12858.  
  12859. OS/2 Notes
  12860. ----------
  12861.  
  12862. MySQL uses quite a few open files. Because of this, you should add
  12863. something like the following to your `CONFIG.SYS' file:
  12864.  
  12865.      SET EMXOPT=-c -n -h1024
  12866.  
  12867. If you don't do this, you will probably run into the following error:
  12868.  
  12869.      File 'XXXX' not found (Errcode: 24)
  12870.  
  12871. When using MySQL with OS/2 Warp 3, FixPack 29 or above is required.
  12872. With OS/2 Warp 4, FixPack 4 or above is required. This is a requirement
  12873. of the Pthreads library.  MySQL must be installed on a partition with a
  12874. type that supports long filenames, such as HPFS, FAT32, and so on.
  12875.  
  12876. The `INSTALL.CMD' script must be run from OS/2's own `CMD.EXE' and may
  12877. not work with replacement shells such as `4OS2.EXE'.
  12878.  
  12879. The `scripts/mysql-install-db' script has been renamed.  It is now
  12880. called `install.cmd' and is a REXX script, which will set up the default
  12881. MySQL security settings and create the WorkPlace Shell icons for MySQL.
  12882.  
  12883. Dynamic module support is compiled in but not fully tested. Dynamic
  12884. modules should be compiled using the Pthreads runtime library.
  12885.  
  12886.      gcc -Zdll -Zmt -Zcrtdll=pthrdrtl -I../include -I../regex -I.. \
  12887.          -o example udf_example.cc -L../lib -lmysqlclient udf_example.def
  12888.      mv example.dll example.udf
  12889.  
  12890. *Note*: Due to limitations in OS/2, UDF module name stems must not
  12891. exceed eight characters. Modules are stored in the `/mysql2/udf'
  12892. directory; the `safe-mysqld.cmd' script will put this directory in the
  12893. `BEGINLIBPATH' environment variable. When using UDF modules, specified
  12894. extensions are ignored--it is assumed to be `.udf'.  For example, in
  12895. Unix, the shared module might be named `example.so' and you would load
  12896. a function from it like this:
  12897.  
  12898.      mysql> CREATE FUNCTION metaphon RETURNS STRING SONAME 'example.so';
  12899.  
  12900. In OS/2, the module would be named `example.udf', but you would not
  12901. specify the module extension:
  12902.  
  12903.      mysql> CREATE FUNCTION metaphon RETURNS STRING SONAME 'example';
  12904.  
  12905. BeOS Notes
  12906. ----------
  12907.  
  12908. We have in the past talked with some BeOS developers who have said that
  12909. MySQL is 80% ported to BeOS, but we haven't heard from them in a while.
  12910.  
  12911. Perl Installation Notes
  12912. =======================
  12913.  
  12914. Perl support for MySQL is provided by means of the `DBI'/`DBD' client
  12915. interface. The interface requires Perl Version 5.6.0 or later.  It
  12916. _will not work_ if you have an older version of Perl.
  12917.  
  12918. If you want to use transactions with Perl DBI, you need to have
  12919. `DBD::mysql' version 1.2216 or newer. Version 2.9003 or newer is
  12920. recommended.
  12921.  
  12922. If you are using the MySQL 4.1 client library, you must use
  12923. `DBD::mysql' 2.9003 or newer.
  12924.  
  12925. As of MySQL 3.22.8, Perl support is no longer included with MySQL
  12926. distributions. You can obtain the necessary modules from
  12927. `http://search.cpan.org' for Unix, or by using the ActiveState `ppm'
  12928. program on Windows. The following sections describe how to do this.
  12929.  
  12930. Perl support for MySQL must be installed if you want to run the MySQL
  12931. benchmark scripts.  *Note MySQL Benchmarks::.
  12932.  
  12933. Installing Perl on Unix
  12934. -----------------------
  12935.  
  12936. MySQL Perl support requires that you've installed MySQL client
  12937. programming support (libraries and header files).  Most installation
  12938. methods install the necessary files. However, if you installed MySQL
  12939. from RPM files on Linux, be sure that you've installed the developer
  12940. RPM.  The client programs are in the client RPM, but client programming
  12941. support is in the developer RPM.
  12942.  
  12943. If you want to install Perl support, the files you will need can be
  12944. obtained from the CPAN (Comprehensive Perl Archive Network) at
  12945. `http://search.cpan.org'.
  12946.  
  12947. The easiest way to install Perl modules on Unix is to use the `CPAN'
  12948. module. For example:
  12949.  
  12950.      shell> perl -MCPAN -e shell
  12951.      cpan> install DBI
  12952.      cpan> install DBD::mysql
  12953.  
  12954. The `DBD::mysql' installation runs a number of tests.  These tests
  12955. require being able to connect to the local MySQL server as the
  12956. anonymous user with no password. If you have removed anonymous accounts
  12957. or assigned them passwords, the tests fail. You can use `force install
  12958. DBD::mysql' to ignore the failed tests.
  12959.  
  12960. `DBI' requires the `Data::Dumper' module. It may already be installed;
  12961. if not, you should install it before installing `DBI'.
  12962.  
  12963. It is also possible to download the module distributions in the form of
  12964. compressed `tar' archives and build the modules manually. For example,
  12965. to unpack and build a DBI distribution, use a procedure such as this:
  12966.  
  12967.   1. Unpack the distribution into the current directory:
  12968.           shell> gunzip < DBI-VERSION.tar.gz | tar xvf -
  12969.      This command creates a directory named `DBI-VERSION'.
  12970.  
  12971.   2. Change location into the top-level directory of the unpacked
  12972.      distribution:
  12973.           shell> cd DBI-VERSION
  12974.  
  12975.   3. Build the distribution and compile everything:
  12976.           shell> perl Makefile.PL
  12977.           shell> make
  12978.           shell> make test
  12979.           shell> make install
  12980.  
  12981. The `make test' command is important because it verifies that the
  12982. module is working.  Note that when you run that command during the
  12983. `DBD::mysql' installation to exercise the interface code, the MySQL
  12984. server must be running or the test will fail.
  12985.  
  12986. It is a good idea to rebuild and reinstall the `DBD::mysql'
  12987. distribution whenever you install a new release of MySQL, particularly
  12988. if you notice symptoms such as that all your `DBI' scripts fail after
  12989. you upgrade MySQL.
  12990.  
  12991. If you don't have access rights to install Perl modules in the system
  12992. directory or if you want to install local Perl modules, the following
  12993. reference may be useful:
  12994. `http://servers.digitaldaze.com/extensions/perl/modules.html#modules'
  12995.  
  12996. Look under the heading "Installing New Modules that Require Locally
  12997. Installed Modules."
  12998.  
  12999. Installing ActiveState Perl on Windows
  13000. --------------------------------------
  13001.  
  13002. On Windows, you should do the following to install the MySQL `DBD'
  13003. module with ActiveState Perl:
  13004.  
  13005.    * Get ActiveState Perl from
  13006.      `http://www.activestate.com/Products/ActivePerl/' and install it.
  13007.  
  13008.    * Open a console window (a "DOS window").
  13009.  
  13010.    * If required, set the `HTTP_proxy' variable. For example, you might
  13011.      try:
  13012.  
  13013.           set HTTP_proxy=my.proxy.com:3128
  13014.  
  13015.    * Start the PPM program:
  13016.  
  13017.           C:\> C:\perl\bin\ppm.pl
  13018.  
  13019.    * If you have not already done so, install `DBI':
  13020.  
  13021.           ppm> install DBI
  13022.  
  13023.    * If this succeeds, run the following command:
  13024.  
  13025.           install \
  13026.           ftp://ftp.de.uu.net/pub/CPAN/authors/id/JWIED/DBD-mysql-1.2212.x86.ppd
  13027.  
  13028. This procedure should work at least with ActiveState Perl Version 5.6.
  13029.  
  13030. If you can't get the procedure to work, you should instead install the
  13031. `MyODBC' driver and connect to the MySQL server through ODBC:
  13032.  
  13033.      use DBI;
  13034.      $dbh= DBI->connect("DBI:ODBC:$dsn",$user,$password) ||
  13035.        die "Got error $DBI::errstr when connecting to $dsn\n";
  13036.  
  13037. Problems Using the Perl `DBI'/`DBD' Interface
  13038. ---------------------------------------------
  13039.  
  13040. If Perl reports that it can't find the `../mysql/mysql.so' module, then
  13041. the problem is probably that Perl can't locate the shared library
  13042. `libmysqlclient.so'.
  13043.  
  13044. You should be able to fix this by one of the following methods:
  13045.  
  13046.    * Compile the `DBD::mysql' distribution with `perl Makefile.PL
  13047.      -static -config' rather than `perl Makefile.PL'.
  13048.  
  13049.    * Copy `libmysqlclient.so' to the directory where your other shared
  13050.      libraries are located (probably `/usr/lib' or `/lib').
  13051.  
  13052.    * Modify the `-L' options used to compile `DBD::mysql' to reflect
  13053.      the actual location of `libmysqlclient.so'.
  13054.  
  13055.    * On Linux, you can add the pathname of the directory where
  13056.      `libmysqlclient.so' is located to the `/etc/ld.so.conf' file.
  13057.  
  13058.    * Add the pathname of the directory where `libmysqlclient.so' is
  13059.      located to the `LD_RUN_PATH' environment variable. Some systems use
  13060.      `LD_LIBRARY_PATH' instead.
  13061.  
  13062. Note that you may also need to modify the `-L' options if there are
  13063. other libraries that the linker fails to find. For example, if the
  13064. linker cannot find `libc' because it is in `/lib' and the link command
  13065. specifies `-L/usr/lib', change the `-L' option to `-L/lib' or add
  13066. `-L/lib' to the existing link command.
  13067.  
  13068. If you get the following errors from `DBD::mysql', you are probably
  13069. using `gcc' (or using an old binary compiled with `gcc'):
  13070.  
  13071.      /usr/bin/perl: can't resolve symbol '__moddi3'
  13072.      /usr/bin/perl: can't resolve symbol '__divdi3'
  13073.  
  13074. Add `-L/usr/lib/gcc-lib/... -lgcc' to the link command when the
  13075. `mysql.so' library gets built (check the output from `make' for
  13076. `mysql.so' when you compile the Perl client).  The `-L' option should
  13077. specify the pathname of the directory where `libgcc.a' is located on
  13078. your system.
  13079.  
  13080. Another cause of this problem may be that Perl and MySQL aren't both
  13081. compiled with `gcc'.  In this case, you can solve the mismatch by
  13082. compiling both with `gcc'.
  13083.  
  13084. You may see the following error from `DBD::mysql' when you run the
  13085. tests:
  13086.  
  13087.      t/00base............install_driver(mysql) failed:
  13088.      Can't load '../blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql:
  13089.      ../blib/arch/auto/DBD/mysql/mysql.so: undefined symbol:
  13090.      uncompress at /usr/lib/perl5/5.00503/i586-linux/DynaLoader.pm line 169.
  13091.  
  13092. This means that you need to include the `-lz' compression library on the
  13093. link line. That can be done by changing the following line in the file
  13094. `lib/DBD/mysql/Install.pm':
  13095.  
  13096.      $sysliblist .= " -lm";
  13097.  
  13098. Change that line to:
  13099.  
  13100.      $sysliblist .= " -lm -lz";
  13101.  
  13102. After this, you _must_ run `make realclean' and then proceed with the
  13103. installation from the beginning.
  13104.  
  13105. If you want to install DBI on SCO, you have to edit the `Makefile' in
  13106. DBI-XXX and each subdirectory.  Note that the following assumes `gcc'
  13107. 2.95.2 or newer:
  13108.  
  13109.      OLD:                                  NEW:
  13110.      CC = cc                               CC = gcc
  13111.      CCCDLFLAGS = -KPIC -W1,-Bexport       CCCDLFLAGS = -fpic
  13112.      CCDLFLAGS = -wl,-Bexport              CCDLFLAGS =
  13113.      
  13114.      LD = ld                               LD = gcc -G -fpic
  13115.      LDDLFLAGS = -G -L/usr/local/lib       LDDLFLAGS = -L/usr/local/lib
  13116.      LDFLAGS = -belf -L/usr/local/lib      LDFLAGS = -L/usr/local/lib
  13117.      
  13118.      LD = ld                               LD = gcc -G -fpic
  13119.      OPTIMISE = -Od                        OPTIMISE = -O1
  13120.      
  13121.      OLD:
  13122.      CCCFLAGS = -belf -dy -w0 -U M_XENIX -DPERL_SCO5 -I/usr/local/include
  13123.      
  13124.      NEW:
  13125.      CCFLAGS = -U M_XENIX -DPERL_SCO5 -I/usr/local/include
  13126.  
  13127. These changes are necessary because the Perl dynaloader will not load
  13128. the `DBI' modules if they were compiled with `icc' or `cc'.
  13129.  
  13130. If you want to use the Perl module on a system that doesn't support
  13131. dynamic linking (such as SCO), you can generate a static version of
  13132. Perl that includes `DBI' and `DBD::mysql'.  The way this works is that
  13133. you generate a version of Perl with the `DBI' code linked in and
  13134. install it on top of your current Perl.  Then you use that to build a
  13135. version of Perl that additionally has the `DBD' code linked in, and
  13136. install that.
  13137.  
  13138. On SCO, you must have the following environment variables set:
  13139.  
  13140.      LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:/usr/progressive/lib
  13141.  
  13142. Or:
  13143.  
  13144.      LD_LIBRARY_PATH=/usr/lib:/lib:/usr/local/lib:/usr/ccs/lib:\
  13145.          /usr/progressive/lib:/usr/skunk/lib
  13146.      LIBPATH=/usr/lib:/lib:/usr/local/lib:/usr/ccs/lib:\
  13147.          /usr/progressive/lib:/usr/skunk/lib
  13148.      MANPATH=scohelp:/usr/man:/usr/local1/man:/usr/local/man:\
  13149.          /usr/skunk/man:
  13150.  
  13151. First, create a Perl that includes a statically linked `DBI' module by
  13152. running these commands in the directory where your `DBI' distribution is
  13153. located:
  13154.  
  13155.      shell> perl Makefile.PL -static -config
  13156.      shell> make
  13157.      shell> make install
  13158.      shell> make perl
  13159.  
  13160. Then you must install the new Perl. The output of `make perl' will
  13161. indicate the exact `make' command you will need to execute to perform
  13162. the installation.  On SCO, this is `make -f Makefile.aperl inst_perl
  13163. MAP_TARGET=perl'.
  13164.  
  13165. Next, use the just-created Perl to create another Perl that also
  13166. includes a statically linked `DBD::mysql' by running these commands in
  13167. the directory where your `DBD::mysql' distribution is located:
  13168.  
  13169.      shell> perl Makefile.PL -static -config
  13170.      shell> make
  13171.      shell> make install
  13172.      shell> make perl
  13173.  
  13174. Finally, you should install this new Perl.  Again, the output of `make
  13175. perl' indicates the command to use.
  13176.  
  13177. MySQL Tutorial
  13178. **************
  13179.  
  13180. This chapter provides a tutorial introduction to MySQL by showing how
  13181. to use the `mysql' client program to create and use a simple database.
  13182. `mysql' (sometimes referred to as the "terminal monitor" or just
  13183. "monitor") is an interactive program that allows you to connect to a
  13184. MySQL server, run queries, and view the results.  `mysql' may also be
  13185. used in batch mode: you place your queries in a file beforehand, then
  13186. tell `mysql' to execute the contents of the file.  Both ways of using
  13187. `mysql' are covered here.
  13188.  
  13189. To see a list of options provided by `mysql', invoke it with the
  13190. `--help' option:
  13191.  
  13192.      shell> mysql --help
  13193.  
  13194. This chapter assumes that `mysql' is installed on your machine and that
  13195. a MySQL server is available to which you can connect.  If this is not
  13196. true, contact your MySQL administrator.  (If *you* are the
  13197. administrator, you will need to consult other sections of this manual.)
  13198.  
  13199. This chapter describes the entire process of setting up and using a
  13200. database.  If you are interested only in accessing an already-existing
  13201. database, you may want to skip over the sections that describe how to
  13202. create the database and the tables it contains.
  13203.  
  13204. Because this chapter is tutorial in nature, many details are necessarily
  13205. omitted.  Consult the relevant sections of the manual for more
  13206. information on the topics covered here.
  13207.  
  13208. Connecting to and Disconnecting from the Server
  13209. ===============================================
  13210.  
  13211. To connect to the server, you'll usually need to provide a MySQL
  13212. username when you invoke `mysql' and, most likely, a password.  If the
  13213. server runs on a machine other than the one where you log in, you'll
  13214. also need to specify a hostname.  Contact your administrator to find
  13215. out what connection parameters you should use to connect (that is, what
  13216. host, username, and password to use).  Once you know the proper
  13217. parameters, you should be able to connect like this:
  13218.  
  13219.      shell> mysql -h HOST -u USER -p
  13220.      Enter password: ********
  13221.  
  13222. `host' and `user' represent the hostname where your MySQL server is
  13223. running and the username of your MySQL account.  Substitute appropriate
  13224. values for your setup.  The `********' represents your password; enter
  13225. it when `mysql' displays the `Enter password:' prompt.
  13226.  
  13227. If that works, you should see some introductory information followed by
  13228. a `mysql>' prompt:
  13229.  
  13230.      shell> mysql -h HOST -u USER -p
  13231.      Enter password: ********
  13232.      Welcome to the MySQL monitor.  Commands end with ; or \g.
  13233.      Your MySQL connection id is 25338 to server version: 4.0.14-log
  13234.      
  13235.      Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  13236.      
  13237.      mysql>
  13238.  
  13239. The prompt tells you that `mysql' is ready for you to enter commands.
  13240.  
  13241. Some MySQL installations allow users to connect as the anonymous
  13242. (unnamed) user to the server running on the local host.  If this is the
  13243. case on your machine, you should be able to connect to that server by
  13244. invoking `mysql' without any options:
  13245.  
  13246.      shell> mysql
  13247.  
  13248. After you have connected successfully, you can disconnect any time by
  13249. typing `QUIT' (or `\q') at the `mysql>' prompt:
  13250.  
  13251.      mysql> QUIT
  13252.      Bye
  13253.  
  13254. On Unix, you can also disconnect by pressing Control-D.
  13255.  
  13256. Most examples in the following sections assume that you are connected
  13257. to the server.  They indicate this by the `mysql>' prompt.
  13258.  
  13259. Entering Queries
  13260. ================
  13261.  
  13262. Make sure that you are connected to the server, as discussed in the
  13263. previous section.  Doing so will not in itself select any database to
  13264. work with, but that's okay.  At this point, it's more important to find
  13265. out a little about how to issue queries than to jump right in creating
  13266. tables, loading data into them, and retrieving data from them.  This
  13267. section describes the basic principles of entering commands, using
  13268. several queries you can try out to familiarize yourself with how
  13269. `mysql' works.
  13270.  
  13271. Here's a simple command that asks the server to tell you its version
  13272. number and the current date.  Type it in as shown here following the
  13273. `mysql>' prompt and press Enter:
  13274.  
  13275.      mysql> SELECT VERSION(), CURRENT_DATE;
  13276.      +--------------+--------------+
  13277.      | VERSION()    | CURRENT_DATE |
  13278.      +--------------+--------------+
  13279.      | 3.22.20a-log | 1999-03-19   |
  13280.      +--------------+--------------+
  13281.      1 row in set (0.01 sec)
  13282.      mysql>
  13283.  
  13284. This query illustrates several things about `mysql':
  13285.  
  13286.    * A command normally consists of an SQL statement followed by a
  13287.      semicolon.  (There are some exceptions where a semicolon may be
  13288.      omitted.  `QUIT', mentioned earlier, is one of them.  We'll get to
  13289.      others later.)
  13290.  
  13291.    * When you issue a command, `mysql' sends it to the server for
  13292.      execution and displays the results, then prints another `mysql>'
  13293.      prompt to indicate that it is ready for another command.
  13294.  
  13295.    * `mysql' displays query output in tabular form (rows and columns).
  13296.      The first row contains labels for the columns.  The rows following
  13297.      are the query results.  Normally, column labels are the names of
  13298.      the columns you fetch from database tables.  If you're retrieving
  13299.      the value of an expression rather than a table column (as in the
  13300.      example just shown), `mysql' labels the column using the
  13301.      expression itself.
  13302.  
  13303.    * `mysql' shows how many rows were returned and how long the query
  13304.      took to execute, which gives you a rough idea of server
  13305.      performance.  These values are imprecise because they represent
  13306.      wall clock time (not CPU or machine time), and because they are
  13307.      affected by factors such as server load and network latency.  (For
  13308.      brevity, the "rows in set" line is not shown in the remaining
  13309.      examples in this chapter.)
  13310.  
  13311. Keywords may be entered in any lettercase.  The following queries are
  13312. equivalent:
  13313.  
  13314.      mysql> SELECT VERSION(), CURRENT_DATE;
  13315.      mysql> select version(), current_date;
  13316.      mysql> SeLeCt vErSiOn(), current_DATE;
  13317.  
  13318. Here's another query.  It demonstrates that you can use `mysql' as a
  13319. simple calculator:
  13320.  
  13321.      mysql> SELECT SIN(PI()/4), (4+1)*5;
  13322.      +-------------+---------+
  13323.      | SIN(PI()/4) | (4+1)*5 |
  13324.      +-------------+---------+
  13325.      |    0.707107 |      25 |
  13326.      +-------------+---------+
  13327.  
  13328. The queries shown thus far have been relatively short, single-line
  13329. statements.  You can even enter multiple statements on a single line.
  13330. Just end each one with a semicolon:
  13331.  
  13332.      mysql> SELECT VERSION(); SELECT NOW();
  13333.      +--------------+
  13334.      | VERSION()    |
  13335.      +--------------+
  13336.      | 3.22.20a-log |
  13337.      +--------------+
  13338.      
  13339.      +---------------------+
  13340.      | NOW()               |
  13341.      +---------------------+
  13342.      | 1999-03-19 00:15:33 |
  13343.      +---------------------+
  13344.  
  13345. A command need not be given all on a single line, so lengthy commands
  13346. that require several lines are not a problem.  `mysql' determines where
  13347. your statement ends by looking for the terminating semicolon, not by
  13348. looking for the end of the input line.  (In other words, `mysql'
  13349. accepts free-format input:  it collects input lines but does not
  13350. execute them until it sees the semicolon.)
  13351.  
  13352. Here's a simple multiple-line statement:
  13353.  
  13354.      mysql> SELECT
  13355.          -> USER()
  13356.          -> ,
  13357.          -> CURRENT_DATE;
  13358.      +--------------------+--------------+
  13359.      | USER()             | CURRENT_DATE |
  13360.      +--------------------+--------------+
  13361.      | joesmith@localhost | 1999-03-18   |
  13362.      +--------------------+--------------+
  13363.  
  13364. In this example, notice how the prompt changes from `mysql>' to `->'
  13365. after you enter the first line of a multiple-line query.  This is how
  13366. `mysql' indicates that it hasn't seen a complete statement and is
  13367. waiting for the rest.  The prompt is your friend, because it provides
  13368. valuable feedback.  If you use that feedback, you will always be aware
  13369. of what `mysql' is waiting for.
  13370.  
  13371. If you decide you don't want to execute a command that you are in the
  13372. process of entering, cancel it by typing `\c':
  13373.  
  13374.      mysql> SELECT
  13375.          -> USER()
  13376.          -> \c
  13377.      mysql>
  13378.  
  13379. Here, too, notice the prompt.  It switches back to `mysql>' after you
  13380. type `\c', providing feedback to indicate that `mysql' is ready for a
  13381. new command.
  13382.  
  13383. The following table shows each of the prompts you may see and
  13384. summarizes what they mean about the state that `mysql' is in:
  13385.  
  13386. *Prompt**Meaning*
  13387. `mysql>'Ready for new command.
  13388. `       Waiting for next line of multiple-line command.
  13389. ->'     
  13390. `       Waiting for next line, collecting a string that begins
  13391. '>'     with a single quote (`'').
  13392. `       Waiting for next line, collecting a string that begins
  13393. ">'     with a double quote (`"').
  13394. `       Waiting for next line, collecting an identifier that
  13395. `>'     begins with a backtick (``').
  13396.  
  13397. Multiple-line statements commonly occur by accident when you intend to
  13398. issue a command on a single line, but forget the terminating semicolon.
  13399. In this case, `mysql' waits for more input:
  13400.  
  13401.      mysql> SELECT USER()
  13402.          ->
  13403.  
  13404. If this happens to you (you think you've entered a statement but the
  13405. only response is a `->' prompt), most likely `mysql' is waiting for the
  13406. semicolon.  If you don't notice what the prompt is telling you, you
  13407. might sit there for a while before realising what you need to do.
  13408. Enter a semicolon to complete the statement, and `mysql' will execute
  13409. it:
  13410.  
  13411.      mysql> SELECT USER()
  13412.          -> ;
  13413.      +--------------------+
  13414.      | USER()             |
  13415.      +--------------------+
  13416.      | joesmith@localhost |
  13417.      +--------------------+
  13418.  
  13419. The `'>' and `">' prompts occur during string collection.  In MySQL,
  13420. you can write strings surrounded by either `'' or `"' characters (for
  13421. example, `'hello'' or `"goodbye"'), and `mysql' lets you enter strings
  13422. that span multiple lines.  When you see a `'>' or `">' prompt, it means
  13423. that you've entered a line containing a string that begins with a `''
  13424. or `"' quote character, but have not yet entered the matching quote
  13425. that terminates the string.  That's fine if you really are entering a
  13426. multiple-line string, but how likely is that?  Not very.  More often,
  13427. the `'>' and `">' prompts indicate that you've inadvertantly left out a
  13428. quote character.  For example:
  13429.  
  13430.      mysql> SELECT * FROM my_table WHERE name = 'Smith AND age < 30;
  13431.          '>
  13432.  
  13433. If you enter this `SELECT' statement, then press Enter and wait for the
  13434. result, nothing will happen.  Instead of wondering why this query takes
  13435. so long, notice the clue provided by the `'>' prompt.  It tells you
  13436. that `mysql' expects to see the rest of an unterminated string.  (Do
  13437. you see the error in the statement?  The string `'Smith' is missing the
  13438. second quote.)
  13439.  
  13440. At this point, what do you do?  The simplest thing is to cancel the
  13441. command.  However, you cannot just type `\c' in this case, because
  13442. `mysql' interprets it as part of the string that it is collecting!
  13443. Instead, enter the closing quote character (so `mysql' knows you've
  13444. finished the string), then type `\c':
  13445.  
  13446.      mysql> SELECT * FROM my_table WHERE name = 'Smith AND age < 30;
  13447.          '> '\c
  13448.      mysql>
  13449.  
  13450. The prompt changes back to `mysql>', indicating that `mysql' is ready
  13451. for a new command.
  13452.  
  13453. The ``>' prompt is similar to th `'>' and `">' prompts, but indicates
  13454. that you have begun but not completed a backtick-quoted identifier.
  13455.  
  13456. It's important to know what the `'>', `">', and ``>' prompts signify,
  13457. because if you mistakenly enter an unterminated string, any further
  13458. lines you type will appear to be ignored by `mysql'--including a line
  13459. containing `QUIT'!  This can be quite confusing, especially if you
  13460. don't know that you need to supply the terminating quote before you can
  13461. cancel the current command.
  13462.  
  13463. Creating and Using a Database
  13464. =============================
  13465.  
  13466. Now that you know how to enter commands, it's time to access a database.
  13467.  
  13468. Suppose that you have several pets in your home (your menagerie) and
  13469. you'd like to keep track of various types of information about them.
  13470. You can do so by creating tables to hold your data and loading them
  13471. with the desired information.  Then you can answer different sorts of
  13472. questions about your animals by retrieving data from the tables.  This
  13473. section shows you how to:
  13474.  
  13475.    * Create a database
  13476.  
  13477.    * Create a table
  13478.  
  13479.    * Load data into the table
  13480.  
  13481.    * Retrieve data from the table in various ways
  13482.  
  13483.    * Use multiple tables
  13484.  
  13485. The menagerie database will be simple (deliberately), but it is not
  13486. difficult to think of real-world situations in which a similar type of
  13487. database might be used.  For example, a database like this could be
  13488. used by a farmer to keep track of livestock, or by a veterinarian to
  13489. keep track of patient records.  A menagerie distribution containing
  13490. some of the queries and sample data used in the following sections can
  13491. be obtained from the MySQL Web site.  It's available in either
  13492. compressed `tar' format
  13493. (`http://www.mysql.com/Downloads/Contrib/Examples/menagerie.tar.gz') or
  13494. Zip format
  13495. (`http://www.mysql.com/Downloads/Contrib/Examples/menagerie.zip').
  13496.  
  13497. Use the `SHOW' statement to find out what databases currently exist on
  13498. the server:
  13499.  
  13500.      mysql> SHOW DATABASES;
  13501.      +----------+
  13502.      | Database |
  13503.      +----------+
  13504.      | mysql    |
  13505.      | test     |
  13506.      | tmp      |
  13507.      +----------+
  13508.  
  13509. The list of databases is probably different on your machine, but the
  13510. `mysql' and `test' databases are likely to be among them.  The `mysql'
  13511. database is required because it describes user access privileges.  The
  13512. `test' database is often provided as a workspace for users to try
  13513. things out.
  13514.  
  13515. Note that you may not see all databases if you don't have the `SHOW
  13516. DATABASES' privilege. *Note `GRANT': GRANT.
  13517.  
  13518. If the `test' database exists, try to access it:
  13519.  
  13520.      mysql> USE test
  13521.      Database changed
  13522.  
  13523. Note that `USE', like `QUIT', does not require a semicolon.  (You can
  13524. terminate such statements with a semicolon if you like; it does no
  13525. harm.)  The `USE' statement is special in another way, too:  it must be
  13526. given on a single line.
  13527.  
  13528. You can use the `test' database (if you have access to it) for the
  13529. examples that follow, but anything you create in that database can be
  13530. removed by anyone else with access to it.  For this reason, you should
  13531. probably ask your MySQL administrator for permission to use a database
  13532. of your own.  Suppose that you want to call yours `menagerie'.  The
  13533. administrator needs to execute a command like this:
  13534.  
  13535.      mysql> GRANT ALL ON menagerie.* TO 'your_mysql_name'@'your_client_host';
  13536.  
  13537. where `your_mysql_name' is the MySQL username assigned to you and
  13538. `your_client_host' is the host from which you connect to the server.
  13539.  
  13540. Creating and Selecting a Database
  13541. ---------------------------------
  13542.  
  13543. If the administrator creates your database for you when setting up your
  13544. permissions, you can begin using it.  Otherwise, you need to create it
  13545. yourself:
  13546.  
  13547.      mysql> CREATE DATABASE menagerie;
  13548.  
  13549. Under Unix, database names are case sensitive (unlike SQL keywords), so
  13550. you must always refer to your database as `menagerie', not as
  13551. `Menagerie', `MENAGERIE', or some other variant.  This is also true for
  13552. table names.  (Under Windows, this restriction does not apply, although
  13553. you must refer to databases and tables using the same lettercase
  13554. throughout a given query.)
  13555.  
  13556. Creating a database does not select it for use; you must do that
  13557. explicitly.  To make `menagerie' the current database, use this command:
  13558.  
  13559.      mysql> USE menagerie
  13560.      Database changed
  13561.  
  13562. Your database needs to be created only once, but you must select it for
  13563. use each time you begin a `mysql' session.  You can do this by issuing a
  13564. `USE' statement as shown in the example.  Alternatively, you can select
  13565. the database on the command line when you invoke `mysql'.  Just specify
  13566. its name after any connection parameters that you might need to
  13567. provide.  For example:
  13568.  
  13569.      shell> mysql -h HOST -u USER -p menagerie
  13570.      Enter password: ********
  13571.  
  13572. Note that `menagerie' is not your password on the command just shown.
  13573. If you want to supply your password on the command line after the `-p'
  13574. option, you must do so with no intervening space (for example, as
  13575. `-pmypassword', not as `-p mypassword').  However, putting your
  13576. password on the command line is not recommended, because doing so
  13577. exposes it to snooping by other users logged in on your machine.
  13578.  
  13579. Creating a Table
  13580. ----------------
  13581.  
  13582. Creating the database is the easy part, but at this point it's empty, as
  13583. `SHOW TABLES' will tell you:
  13584.  
  13585.      mysql> SHOW TABLES;
  13586.      Empty set (0.00 sec)
  13587.  
  13588. The harder part is deciding what the structure of your database should
  13589. be: what tables you will need and what columns will be in each of them.
  13590.  
  13591. You'll want a table that contains a record for each of your pets.  This
  13592. can be called the `pet' table, and it should contain, as a bare minimum,
  13593. each animal's name.  Because the name by itself is not very
  13594. interesting, the table should contain other information.  For example,
  13595. if more than one person in your family keeps pets, you might want to
  13596. list each animal's owner.  You might also want to record some basic
  13597. descriptive information such as species and sex.
  13598.  
  13599. How about age?  That might be of interest, but it's not a good thing to
  13600. store in a database.  Age changes as time passes, which means you'd
  13601. have to update your records often.  Instead, it's better to store a
  13602. fixed value such as date of birth.  Then, whenever you need age, you
  13603. can calculate it as the difference between the current date and the
  13604. birth date.  MySQL provides functions for doing date arithmetic, so
  13605. this is not difficult.  Storing birth date rather than age has other
  13606. advantages, too:
  13607.  
  13608.    * You can use the database for tasks such as generating reminders
  13609.      for upcoming pet birthdays.  (If you think this type of query is
  13610.      somewhat silly, note that it is the same question you might ask in
  13611.      the context of a business database to identify clients to whom
  13612.      you'll soon need to send out birthday greetings, for that
  13613.      computer-assisted personal touch.)
  13614.  
  13615.    * You can calculate age in relation to dates other than the current
  13616.      date.  For example, if you store death date in the database, you
  13617.      can easily calculate how old a pet was when it died.
  13618.  
  13619. You can probably think of other types of information that would be
  13620. useful in the `pet' table, but the ones identified so far are
  13621. sufficient for now: name, owner, species, sex, birth, and death.
  13622.  
  13623. Use a `CREATE TABLE' statement to specify the layout of your table:
  13624.  
  13625.      mysql> CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20),
  13626.          -> species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);
  13627.  
  13628. `VARCHAR' is a good choice for the `name', `owner', and `species'
  13629. columns because the column values will vary in length.  The lengths of
  13630. those columns need not all be the same, and need not be `20'.  You can
  13631. pick any length from `1' to `255', whatever seems most reasonable to
  13632. you.  (If you make a poor choice and it turns out later that you need a
  13633. longer field, MySQL provides an `ALTER TABLE' statement.)
  13634.  
  13635. Several types of values can be chosen to represent sex in animal
  13636. records, such as `'m'' and `'f'', or perhaps `'male'' and `'female''.
  13637. It's simplest to use the single characters `'m'' and `'f''.
  13638.  
  13639. The use of the `DATE' data type for the `birth' and `death' columns is
  13640. a fairly obvious choice.
  13641.  
  13642. Now that you have created a table, `SHOW TABLES' should produce some
  13643. output:
  13644.  
  13645.      mysql> SHOW TABLES;
  13646.      +---------------------+
  13647.      | Tables in menagerie |
  13648.      +---------------------+
  13649.      | pet                 |
  13650.      +---------------------+
  13651.  
  13652. To verify that your table was created the way you expected, use a
  13653. `DESCRIBE' statement:
  13654.  
  13655.      mysql> DESCRIBE pet;
  13656.      +---------+-------------+------+-----+---------+-------+
  13657.      | Field   | Type        | Null | Key | Default | Extra |
  13658.      +---------+-------------+------+-----+---------+-------+
  13659.      | name    | varchar(20) | YES  |     | NULL    |       |
  13660.      | owner   | varchar(20) | YES  |     | NULL    |       |
  13661.      | species | varchar(20) | YES  |     | NULL    |       |
  13662.      | sex     | char(1)     | YES  |     | NULL    |       |
  13663.      | birth   | date        | YES  |     | NULL    |       |
  13664.      | death   | date        | YES  |     | NULL    |       |
  13665.      +---------+-------------+------+-----+---------+-------+
  13666.  
  13667. You can use `DESCRIBE' any time, for example, if you forget the names of
  13668. the columns in your table or what types they have.
  13669.  
  13670. Loading Data into a Table
  13671. -------------------------
  13672.  
  13673. After creating your table, you need to populate it.  The `LOAD DATA' and
  13674. `INSERT' statements are useful for this.
  13675.  
  13676. Suppose that your pet records can be described as shown here.  (Observe
  13677. that MySQL expects dates in `'YYYY-MM-DD'' format; this may be
  13678. different from what you are used to.)
  13679.  
  13680. *name*  *owner* *species**sex**birth*        *death*
  13681. Fluffy  Harold  cat     f    1993-02-04     
  13682. Claws   Gwen    cat     m    1994-03-17     
  13683. Buffy   Harold  dog     f    1989-05-13     
  13684. Fang    Benny   dog     m    1990-08-27     
  13685. Bowser  Diane   dog     m    1979-08-31     1995-07-29
  13686. Chirpy  Gwen    bird    f    1998-09-11     
  13687. WhistlerGwen    bird         1997-12-09     
  13688. Slim    Benny   snake   m    1996-04-29     
  13689.  
  13690. Because you are beginning with an empty table, an easy way to populate
  13691. it is to create a text file containing a row for each of your animals,
  13692. then load the contents of the file into the table with a single
  13693. statement.
  13694.  
  13695. You could create a text file `pet.txt' containing one record per line,
  13696. with values separated by tabs, and given in the order in which the
  13697. columns were listed in the `CREATE TABLE' statement.  For missing
  13698. values (such as unknown sexes or death dates for animals that are still
  13699. living), you can use `NULL' values.  To represent these in your text
  13700. file, use `\N' (backslash, capital-N).  For example, the record for
  13701. Whistler the bird would look like this (where the whitespace between
  13702. values is a single tab character):
  13703.  
  13704. *name*  *owner* *species**sex**birth*        *death*
  13705. `Whistler'`Gwen'  `bird'  `\N' `1997-12-09'   `\N'
  13706.  
  13707. To load the text file `pet.txt' into the `pet' table, use this command:
  13708.  
  13709.      mysql> LOAD DATA LOCAL INFILE '/path/pet.txt' INTO TABLE pet;
  13710.  
  13711. Note that if you created the file on Windows with an editor that uses
  13712. `\r\n' as a line terminator, you should use:
  13713.  
  13714.      mysql> LOAD DATA LOCAL INFILE '/path/pet.txt' INTO TABLE pet
  13715.          -> LINES TERMINATED BY '\r\n';
  13716.  
  13717. You can specify the column value separator and end of line marker
  13718. explicitly in the `LOAD DATA' statement if you wish, but the defaults
  13719. are tab and linefeed.  These are sufficient for the statement to read
  13720. the file `pet.txt' properly.
  13721.  
  13722. If the statement fails, it is likely that your MySQL installation does
  13723. not have local file capability enabled by default.  See *Note `LOAD
  13724. DATA LOCAL': LOAD DATA LOCAL for information on how to change this.
  13725.  
  13726. When you want to add new records one at a time, the `INSERT' statement
  13727. is useful.  In its simplest form, you supply values for each column, in
  13728. the order in which the columns were listed in the `CREATE TABLE'
  13729. statement.  Suppose that Diane gets a new hamster named Puffball.  You
  13730. could add a new record using an `INSERT' statement like this:
  13731.  
  13732.      mysql> INSERT INTO pet
  13733.          -> VALUES ('Puffball','Diane','hamster','f','1999-03-30',NULL);
  13734.  
  13735. Note that string and date values are specified as quoted strings here.
  13736. Also, with `INSERT', you can insert `NULL' directly to represent a
  13737. missing value.  You do not use `\N' like you do with `LOAD DATA'.
  13738.  
  13739. From this example, you should be able to see that there would be a lot
  13740. more typing involved to load your records initially using several
  13741. `INSERT' statements rather than a single `LOAD DATA' statement.
  13742.  
  13743. Retrieving Information from a Table
  13744. -----------------------------------
  13745.  
  13746. The `SELECT' statement is used to pull information from a table.  The
  13747. general form of the statement is:
  13748.  
  13749.      SELECT what_to_select
  13750.      FROM which_table
  13751.      WHERE conditions_to_satisfy;
  13752.  
  13753. `what_to_select' indicates what you want to see.  This can be a list of
  13754. columns, or `*' to indicate "all columns." `which_table' indicates the
  13755. table from which you want to retrieve data.  The `WHERE' clause is
  13756. optional.  If it's present, `conditions_to_satisfy' specifies
  13757. conditions that rows must satisfy to qualify for retrieval.
  13758.  
  13759. Selecting All Data
  13760. ..................
  13761.  
  13762. The simplest form of `SELECT' retrieves everything from a table:
  13763.  
  13764.      mysql> SELECT * FROM pet;
  13765.      +----------+--------+---------+------+------------+------------+
  13766.      | name     | owner  | species | sex  | birth      | death      |
  13767.      +----------+--------+---------+------+------------+------------+
  13768.      | Fluffy   | Harold | cat     | f    | 1993-02-04 | NULL       |
  13769.      | Claws    | Gwen   | cat     | m    | 1994-03-17 | NULL       |
  13770.      | Buffy    | Harold | dog     | f    | 1989-05-13 | NULL       |
  13771.      | Fang     | Benny  | dog     | m    | 1990-08-27 | NULL       |
  13772.      | Bowser   | Diane  | dog     | m    | 1979-08-31 | 1995-07-29 |
  13773.      | Chirpy   | Gwen   | bird    | f    | 1998-09-11 | NULL       |
  13774.      | Whistler | Gwen   | bird    | NULL | 1997-12-09 | NULL       |
  13775.      | Slim     | Benny  | snake   | m    | 1996-04-29 | NULL       |
  13776.      | Puffball | Diane  | hamster | f    | 1999-03-30 | NULL       |
  13777.      +----------+--------+---------+------+------------+------------+
  13778.  
  13779. This form of `SELECT' is useful if you want to review your entire table,
  13780. for example, after you've just loaded it with your initial dataset.  For
  13781. example, you may happen to think that the birth date for Bowser doesn't
  13782. seem quite right.  Consulting your original pedigree papers, you find
  13783. that the correct birth year should be 1989, not 1979.
  13784.  
  13785. There are least a couple of ways to fix this:
  13786.  
  13787.    * Edit the file `pet.txt' to correct the error, then empty the table
  13788.      and reload it using `DELETE' and `LOAD DATA':
  13789.  
  13790.           mysql> DELETE FROM pet;
  13791.           mysql> LOAD DATA LOCAL INFILE 'pet.txt' INTO TABLE pet;
  13792.  
  13793.      However, if you do this, you must also re-enter the record for
  13794.      Puffball.
  13795.  
  13796.    * Fix only the erroneous record with an `UPDATE' statement:
  13797.  
  13798.           mysql> UPDATE pet SET birth = '1989-08-31' WHERE name = 'Bowser';
  13799.  
  13800.      The `UPDATE' changes only the record in question and does not
  13801.      require you to reload the table.
  13802.  
  13803. Selecting Particular Rows
  13804. .........................
  13805.  
  13806. As shown in the preceding section, it is easy to retrieve an entire
  13807. table.  Just omit the `WHERE' clause from the `SELECT' statement.  But
  13808. typically you don't want to see the entire table, particularly when it
  13809. becomes large.  Instead, you're usually more interested in answering a
  13810. particular question, in which case you specify some constraints on the
  13811. information you want.  Let's look at some selection queries in terms of
  13812. questions about your pets that they answer.
  13813.  
  13814. You can select only particular rows from your table.  For example, if
  13815. you want to verify the change that you made to Bowser's birth date,
  13816. select Bowser's record like this:
  13817.  
  13818.      mysql> SELECT * FROM pet WHERE name = 'Bowser';
  13819.      +--------+-------+---------+------+------------+------------+
  13820.      | name   | owner | species | sex  | birth      | death      |
  13821.      +--------+-------+---------+------+------------+------------+
  13822.      | Bowser | Diane | dog     | m    | 1989-08-31 | 1995-07-29 |
  13823.      +--------+-------+---------+------+------------+------------+
  13824.  
  13825. The output confirms that the year is correctly recorded now as 1989,
  13826. not 1979.
  13827.  
  13828. String comparisons normally are case-insensitive, so you can specify the
  13829. name as `'bowser'', `'BOWSER'', etc.  The query result will be the same.
  13830.  
  13831. You can specify conditions on any column, not just `name'.  For example,
  13832. if you want to know which animals were born after 1998, test the `birth'
  13833. column:
  13834.  
  13835.      mysql> SELECT * FROM pet WHERE birth >= '1998-1-1';
  13836.      +----------+-------+---------+------+------------+-------+
  13837.      | name     | owner | species | sex  | birth      | death |
  13838.      +----------+-------+---------+------+------------+-------+
  13839.      | Chirpy   | Gwen  | bird    | f    | 1998-09-11 | NULL  |
  13840.      | Puffball | Diane | hamster | f    | 1999-03-30 | NULL  |
  13841.      +----------+-------+---------+------+------------+-------+
  13842.  
  13843. You can combine conditions, for example, to locate female dogs:
  13844.  
  13845.      mysql> SELECT * FROM pet WHERE species = 'dog' AND sex = 'f';
  13846.      +-------+--------+---------+------+------------+-------+
  13847.      | name  | owner  | species | sex  | birth      | death |
  13848.      +-------+--------+---------+------+------------+-------+
  13849.      | Buffy | Harold | dog     | f    | 1989-05-13 | NULL  |
  13850.      +-------+--------+---------+------+------------+-------+
  13851.  
  13852. The preceding query uses the `AND' logical operator.  There is also an
  13853. `OR' operator:
  13854.  
  13855.      mysql> SELECT * FROM pet WHERE species = 'snake' OR species = 'bird';
  13856.      +----------+-------+---------+------+------------+-------+
  13857.      | name     | owner | species | sex  | birth      | death |
  13858.      +----------+-------+---------+------+------------+-------+
  13859.      | Chirpy   | Gwen  | bird    | f    | 1998-09-11 | NULL  |
  13860.      | Whistler | Gwen  | bird    | NULL | 1997-12-09 | NULL  |
  13861.      | Slim     | Benny | snake   | m    | 1996-04-29 | NULL  |
  13862.      +----------+-------+---------+------+------------+-------+
  13863.  
  13864. `AND' and `OR' may be intermixed, although `AND' has higher precedence
  13865. than `OR'.  If you use both operators, it's a good idea to use
  13866. parentheses to indicate explicitly how conditions should be grouped:
  13867.  
  13868.      mysql> SELECT * FROM pet WHERE (species = 'cat' AND sex = 'm')
  13869.          -> OR (species = 'dog' AND sex = 'f');
  13870.      +-------+--------+---------+------+------------+-------+
  13871.      | name  | owner  | species | sex  | birth      | death |
  13872.      +-------+--------+---------+------+------------+-------+
  13873.      | Claws | Gwen   | cat     | m    | 1994-03-17 | NULL  |
  13874.      | Buffy | Harold | dog     | f    | 1989-05-13 | NULL  |
  13875.      +-------+--------+---------+------+------------+-------+
  13876.  
  13877. Selecting Particular Columns
  13878. ............................
  13879.  
  13880. If you don't want to see entire rows from your table, just name the
  13881. columns in which you're interested, separated by commas.  For example,
  13882. if you want to know when your animals were born, select the `name' and
  13883. `birth' columns:
  13884.  
  13885.      mysql> SELECT name, birth FROM pet;
  13886.      +----------+------------+
  13887.      | name     | birth      |
  13888.      +----------+------------+
  13889.      | Fluffy   | 1993-02-04 |
  13890.      | Claws    | 1994-03-17 |
  13891.      | Buffy    | 1989-05-13 |
  13892.      | Fang     | 1990-08-27 |
  13893.      | Bowser   | 1989-08-31 |
  13894.      | Chirpy   | 1998-09-11 |
  13895.      | Whistler | 1997-12-09 |
  13896.      | Slim     | 1996-04-29 |
  13897.      | Puffball | 1999-03-30 |
  13898.      +----------+------------+
  13899.  
  13900. To find out who owns pets, use this query:
  13901.  
  13902.      mysql> SELECT owner FROM pet;
  13903.      +--------+
  13904.      | owner  |
  13905.      +--------+
  13906.      | Harold |
  13907.      | Gwen   |
  13908.      | Harold |
  13909.      | Benny  |
  13910.      | Diane  |
  13911.      | Gwen   |
  13912.      | Gwen   |
  13913.      | Benny  |
  13914.      | Diane  |
  13915.      +--------+
  13916.  
  13917. However, notice that the query simply retrieves the `owner' field from
  13918. each record, and some of them appear more than once.  To minimize the
  13919. output, retrieve each unique output record just once by adding the
  13920. keyword `DISTINCT':
  13921.  
  13922.      mysql> SELECT DISTINCT owner FROM pet;
  13923.      +--------+
  13924.      | owner  |
  13925.      +--------+
  13926.      | Benny  |
  13927.      | Diane  |
  13928.      | Gwen   |
  13929.      | Harold |
  13930.      +--------+
  13931.  
  13932. You can use a `WHERE' clause to combine row selection with column
  13933. selection.  For example, to get birth dates for dogs and cats only, use
  13934. this query:
  13935.  
  13936.      mysql> SELECT name, species, birth FROM pet
  13937.          -> WHERE species = 'dog' OR species = 'cat';
  13938.      +--------+---------+------------+
  13939.      | name   | species | birth      |
  13940.      +--------+---------+------------+
  13941.      | Fluffy | cat     | 1993-02-04 |
  13942.      | Claws  | cat     | 1994-03-17 |
  13943.      | Buffy  | dog     | 1989-05-13 |
  13944.      | Fang   | dog     | 1990-08-27 |
  13945.      | Bowser | dog     | 1989-08-31 |
  13946.      +--------+---------+------------+
  13947.  
  13948. Sorting Rows
  13949. ............
  13950.  
  13951. You may have noticed in the preceding examples that the result rows are
  13952. displayed in no particular order.  It's often easier to examine query
  13953. output when the rows are sorted in some meaningful way.  To sort a
  13954. result, use an `ORDER BY' clause.
  13955.  
  13956. Here are animal birthdays, sorted by date:
  13957.  
  13958.      mysql> SELECT name, birth FROM pet ORDER BY birth;
  13959.      +----------+------------+
  13960.      | name     | birth      |
  13961.      +----------+------------+
  13962.      | Buffy    | 1989-05-13 |
  13963.      | Bowser   | 1989-08-31 |
  13964.      | Fang     | 1990-08-27 |
  13965.      | Fluffy   | 1993-02-04 |
  13966.      | Claws    | 1994-03-17 |
  13967.      | Slim     | 1996-04-29 |
  13968.      | Whistler | 1997-12-09 |
  13969.      | Chirpy   | 1998-09-11 |
  13970.      | Puffball | 1999-03-30 |
  13971.      +----------+------------+
  13972.  
  13973. On character type columns, sorting--like all other comparison
  13974. operations--is normally performed in a case-insensitive fashion.  This
  13975. means that the order will be undefined for columns that are identical
  13976. except for their case. You can force a case-sensitive sort for a column
  13977. by using the `BINARY' cast: `ORDER BY BINARY col_name'.
  13978.  
  13979. The default sort order is ascending, with smallest values first.  To
  13980. sort in reverse (descending) order, add the `DESC' keyword to the name
  13981. of the column you are sorting by:
  13982.  
  13983.      mysql> SELECT name, birth FROM pet ORDER BY birth DESC;
  13984.      +----------+------------+
  13985.      | name     | birth      |
  13986.      +----------+------------+
  13987.      | Puffball | 1999-03-30 |
  13988.      | Chirpy   | 1998-09-11 |
  13989.      | Whistler | 1997-12-09 |
  13990.      | Slim     | 1996-04-29 |
  13991.      | Claws    | 1994-03-17 |
  13992.      | Fluffy   | 1993-02-04 |
  13993.      | Fang     | 1990-08-27 |
  13994.      | Bowser   | 1989-08-31 |
  13995.      | Buffy    | 1989-05-13 |
  13996.      +----------+------------+
  13997.  
  13998. You can sort on multiple columns, and you can sort columns in different
  13999. directions.  For example, to sort by type of animal in ascending order,
  14000. then by birth date within animal type in descending order (youngest
  14001. animals first), use the following query:
  14002.  
  14003.      mysql> SELECT name, species, birth FROM pet
  14004.          -> ORDER BY species, birth DESC;
  14005.      +----------+---------+------------+
  14006.      | name     | species | birth      |
  14007.      +----------+---------+------------+
  14008.      | Chirpy   | bird    | 1998-09-11 |
  14009.      | Whistler | bird    | 1997-12-09 |
  14010.      | Claws    | cat     | 1994-03-17 |
  14011.      | Fluffy   | cat     | 1993-02-04 |
  14012.      | Fang     | dog     | 1990-08-27 |
  14013.      | Bowser   | dog     | 1989-08-31 |
  14014.      | Buffy    | dog     | 1989-05-13 |
  14015.      | Puffball | hamster | 1999-03-30 |
  14016.      | Slim     | snake   | 1996-04-29 |
  14017.      +----------+---------+------------+
  14018.  
  14019. Note that the `DESC' keyword applies only to the column name immediately
  14020. preceding it (`birth'); it does not affect the `species' column sort
  14021. order.
  14022.  
  14023. Date Calculations
  14024. .................
  14025.  
  14026. MySQL provides several functions that you can use to perform
  14027. calculations on dates, for example, to calculate ages or extract parts
  14028. of dates.
  14029.  
  14030. To determine how many years old each of your pets is, compute the
  14031. difference in the year part of the current date and the birth date, then
  14032. subtract one if the current date occurs earlier in the calendar year
  14033. than the birth date.  The following query shows, for each pet, the
  14034. birth date, the current date, and the age in years.
  14035.  
  14036.      mysql> SELECT name, birth, CURDATE(),
  14037.          -> (YEAR(CURDATE())-YEAR(birth))
  14038.          -> - (RIGHT(CURDATE(),5)<RIGHT(birth,5))
  14039.          -> AS age
  14040.          -> FROM pet;
  14041.      +----------+------------+------------+------+
  14042.      | name     | birth      | CURDATE()  | age  |
  14043.      +----------+------------+------------+------+
  14044.      | Fluffy   | 1993-02-04 | 2003-08-19 |   10 |
  14045.      | Claws    | 1994-03-17 | 2003-08-19 |    9 |
  14046.      | Buffy    | 1989-05-13 | 2003-08-19 |   14 |
  14047.      | Fang     | 1990-08-27 | 2003-08-19 |   12 |
  14048.      | Bowser   | 1989-08-31 | 2003-08-19 |   13 |
  14049.      | Chirpy   | 1998-09-11 | 2003-08-19 |    4 |
  14050.      | Whistler | 1997-12-09 | 2003-08-19 |    5 |
  14051.      | Slim     | 1996-04-29 | 2003-08-19 |    7 |
  14052.      | Puffball | 1999-03-30 | 2003-08-19 |    4 |
  14053.      +----------+------------+------------+------+
  14054.  
  14055. Here, `YEAR()' pulls out the year part of a date and `RIGHT()' pulls
  14056. off the rightmost five characters that represent the `MM-DD' (calendar
  14057. year) part of the date.  The part of the expression that compares the
  14058. `MM-DD' values evaluates to 1 or 0, which adjusts the year difference
  14059. down a year if `CURDATE()' occurs earlier in the year than `birth'.
  14060. The full expression is somewhat ungainly, so an alias (`age') is used
  14061. to make the output column label more meaningful.
  14062.  
  14063. The query works, but the result could be scanned more easily if the rows
  14064. were presented in some order.  This can be done by adding an `ORDER BY
  14065. name' clause to sort the output by name:
  14066.  
  14067.      mysql> SELECT name, birth, CURDATE(),
  14068.          -> (YEAR(CURDATE())-YEAR(birth))
  14069.          -> - (RIGHT(CURDATE(),5)<RIGHT(birth,5))
  14070.          -> AS age
  14071.          -> FROM pet ORDER BY name;
  14072.      +----------+------------+------------+------+
  14073.      | name     | birth      | CURDATE()  | age  |
  14074.      +----------+------------+------------+------+
  14075.      | Bowser   | 1989-08-31 | 2003-08-19 |   13 |
  14076.      | Buffy    | 1989-05-13 | 2003-08-19 |   14 |
  14077.      | Chirpy   | 1998-09-11 | 2003-08-19 |    4 |
  14078.      | Claws    | 1994-03-17 | 2003-08-19 |    9 |
  14079.      | Fang     | 1990-08-27 | 2003-08-19 |   12 |
  14080.      | Fluffy   | 1993-02-04 | 2003-08-19 |   10 |
  14081.      | Puffball | 1999-03-30 | 2003-08-19 |    4 |
  14082.      | Slim     | 1996-04-29 | 2003-08-19 |    7 |
  14083.      | Whistler | 1997-12-09 | 2003-08-19 |    5 |
  14084.      +----------+------------+------------+------+
  14085.  
  14086. To sort the output by `age' rather than `name', just use a different
  14087. `ORDER BY' clause:
  14088.  
  14089.      mysql> SELECT name, birth, CURDATE(),
  14090.          -> (YEAR(CURDATE())-YEAR(birth))
  14091.          -> - (RIGHT(CURDATE(),5)<RIGHT(birth,5))
  14092.          -> AS age
  14093.          -> FROM pet ORDER BY age;
  14094.      +----------+------------+------------+------+
  14095.      | name     | birth      | CURDATE()  | age  |
  14096.      +----------+------------+------------+------+
  14097.      | Chirpy   | 1998-09-11 | 2003-08-19 |    4 |
  14098.      | Puffball | 1999-03-30 | 2003-08-19 |    4 |
  14099.      | Whistler | 1997-12-09 | 2003-08-19 |    5 |
  14100.      | Slim     | 1996-04-29 | 2003-08-19 |    7 |
  14101.      | Claws    | 1994-03-17 | 2003-08-19 |    9 |
  14102.      | Fluffy   | 1993-02-04 | 2003-08-19 |   10 |
  14103.      | Fang     | 1990-08-27 | 2003-08-19 |   12 |
  14104.      | Bowser   | 1989-08-31 | 2003-08-19 |   13 |
  14105.      | Buffy    | 1989-05-13 | 2003-08-19 |   14 |
  14106.      +----------+------------+------------+------+
  14107.  
  14108. A similar query can be used to determine age at death for animals that
  14109. have died.  You determine which animals these are by checking whether
  14110. the `death' value is `NULL'.  Then, for those with non-`NULL' values,
  14111. compute the difference between the `death' and `birth' values:
  14112.  
  14113.      mysql> SELECT name, birth, death,
  14114.          -> (YEAR(death)-YEAR(birth)) - (RIGHT(death,5)<RIGHT(birth,5))
  14115.          -> AS age
  14116.          -> FROM pet WHERE death IS NOT NULL ORDER BY age;
  14117.      +--------+------------+------------+------+
  14118.      | name   | birth      | death      | age  |
  14119.      +--------+------------+------------+------+
  14120.      | Bowser | 1989-08-31 | 1995-07-29 |    5 |
  14121.      +--------+------------+------------+------+
  14122.  
  14123. The query uses `death IS NOT NULL' rather than `death <> NULL' because
  14124. `NULL' is a special value that cannot be compared using the usual
  14125. comparison operators.  This is discussed later.  *Note Working with
  14126. `NULL': Working with NULL.
  14127.  
  14128. What if you want to know which animals have birthdays next month?  For
  14129. this type of calculation, year and day are irrelevant; you simply want
  14130. to extract the month part of the `birth' column.  MySQL provides several
  14131. date-part extraction functions, such as `YEAR()', `MONTH()', and
  14132. `DAYOFMONTH()'.  `MONTH()' is the appropriate function here.  To see
  14133. how it works, run a simple query that displays the value of both
  14134. `birth' and `MONTH(birth)':
  14135.  
  14136.      mysql> SELECT name, birth, MONTH(birth) FROM pet;
  14137.      +----------+------------+--------------+
  14138.      | name     | birth      | MONTH(birth) |
  14139.      +----------+------------+--------------+
  14140.      | Fluffy   | 1993-02-04 |            2 |
  14141.      | Claws    | 1994-03-17 |            3 |
  14142.      | Buffy    | 1989-05-13 |            5 |
  14143.      | Fang     | 1990-08-27 |            8 |
  14144.      | Bowser   | 1989-08-31 |            8 |
  14145.      | Chirpy   | 1998-09-11 |            9 |
  14146.      | Whistler | 1997-12-09 |           12 |
  14147.      | Slim     | 1996-04-29 |            4 |
  14148.      | Puffball | 1999-03-30 |            3 |
  14149.      +----------+------------+--------------+
  14150.  
  14151. Finding animals with birthdays in the upcoming month is easy, too.
  14152. Suppose that the current month is April.  Then the month value is `4'
  14153. and you look for animals born in May (month `5') like this:
  14154.  
  14155.      mysql> SELECT name, birth FROM pet WHERE MONTH(birth) = 5;
  14156.      +-------+------------+
  14157.      | name  | birth      |
  14158.      +-------+------------+
  14159.      | Buffy | 1989-05-13 |
  14160.      +-------+------------+
  14161.  
  14162. There is a small complication if the current month is December.  You
  14163. don't just add one to the month number (`12') and look for animals born
  14164. in month `13', because there is no such month.  Instead, you look for
  14165. animals born in January (month `1').
  14166.  
  14167. You can even write the query so that it works no matter what the current
  14168. month is.  That way you don't have to use a particular month number in
  14169. the query.  `DATE_ADD()' allows you to add a time interval to a given
  14170. date.  If you add a month to the value of `CURDATE()', then extract the
  14171. month part with `MONTH()', the result produces the month in which to
  14172. look for birthdays:
  14173.  
  14174.      mysql> SELECT name, birth FROM pet
  14175.          -> WHERE MONTH(birth) = MONTH(DATE_ADD(CURDATE(),INTERVAL 1 MONTH));
  14176.  
  14177. A different way to accomplish the same task is to add `1' to get the
  14178. next month after the current one (after using the modulo function
  14179. (`MOD') to wrap around the month value to `0' if it is currently `12'):
  14180.  
  14181.      mysql> SELECT name, birth FROM pet
  14182.          -> WHERE MONTH(birth) = MOD(MONTH(CURDATE()), 12) + 1;
  14183.  
  14184. Note that `MONTH' returns a number between `1' and `12'. And
  14185. `MOD(something,12)' returns a number between `0' and `11'. So the
  14186. addition has to be after the `MOD()', otherwise we would go from
  14187. November (`11') to January (`1').
  14188.  
  14189. Working with `NULL' Values
  14190. ..........................
  14191.  
  14192. The `NULL' value can be surprising until you get used to it.
  14193. Conceptually, `NULL' means missing value or unknown value and it is
  14194. treated somewhat differently than other values.  To test for `NULL',
  14195. you cannot use the arithmetic comparison operators such as `=', `<', or
  14196. `<>'.  To demonstrate this for yourself, try the following query:
  14197.  
  14198.      mysql> SELECT 1 = NULL, 1 <> NULL, 1 < NULL, 1 > NULL;
  14199.      +----------+-----------+----------+----------+
  14200.      | 1 = NULL | 1 <> NULL | 1 < NULL | 1 > NULL |
  14201.      +----------+-----------+----------+----------+
  14202.      |     NULL |      NULL |     NULL |     NULL |
  14203.      +----------+-----------+----------+----------+
  14204.  
  14205. Clearly you get no meaningful results from these comparisons.  Use the
  14206. `IS NULL' and `IS NOT NULL' operators instead:
  14207.  
  14208.      mysql> SELECT 1 IS NULL, 1 IS NOT NULL;
  14209.      +-----------+---------------+
  14210.      | 1 IS NULL | 1 IS NOT NULL |
  14211.      +-----------+---------------+
  14212.      |         0 |             1 |
  14213.      +-----------+---------------+
  14214.  
  14215. Note that in MySQL, `0' or `NULL' means false and anything else means
  14216. true. The default truth value from a boolean operation is `1'.
  14217.  
  14218. This special treatment of `NULL' is why, in the previous section, it
  14219. was necessary to determine which animals are no longer alive using
  14220. `death IS NOT NULL' instead of `death <> NULL'.
  14221.  
  14222. Two `NULL' values are regarded as equal in a `GROUP BY'.
  14223.  
  14224. When doing an `ORDER BY', `NULL' values are presented first if you do
  14225. `ORDER BY ... ASC' and last if you do `ORDER BY ... DESC'.
  14226.  
  14227. Note that MySQL 4.0.2 to 4.0.10 incorrectly always sorts `NULL' values
  14228. first regardless of the sort direction.
  14229.  
  14230. Pattern Matching
  14231. ................
  14232.  
  14233. MySQL provides standard SQL pattern matching as well as a form of
  14234. pattern matching based on extended regular expressions similar to those
  14235. used by Unix utilities such as `vi', `grep', and `sed'.
  14236.  
  14237. SQL pattern matching allows you to use `_' to match any single
  14238. character and `%' to match an arbitrary number of characters (including
  14239. zero characters).  In MySQL, SQL patterns are case-insensitive by
  14240. default.  Some examples are shown here.  Note that you do not use `='
  14241. or `<>' when you use SQL patterns; use the `LIKE' or `NOT LIKE'
  14242. comparison operators instead.
  14243.  
  14244. To find names beginning with `b':
  14245.  
  14246.      mysql> SELECT * FROM pet WHERE name LIKE 'b%';
  14247.      +--------+--------+---------+------+------------+------------+
  14248.      | name   | owner  | species | sex  | birth      | death      |
  14249.      +--------+--------+---------+------+------------+------------+
  14250.      | Buffy  | Harold | dog     | f    | 1989-05-13 | NULL       |
  14251.      | Bowser | Diane  | dog     | m    | 1989-08-31 | 1995-07-29 |
  14252.      +--------+--------+---------+------+------------+------------+
  14253.  
  14254. To find names ending with `fy':
  14255.  
  14256.      mysql> SELECT * FROM pet WHERE name LIKE '%fy';
  14257.      +--------+--------+---------+------+------------+-------+
  14258.      | name   | owner  | species | sex  | birth      | death |
  14259.      +--------+--------+---------+------+------------+-------+
  14260.      | Fluffy | Harold | cat     | f    | 1993-02-04 | NULL  |
  14261.      | Buffy  | Harold | dog     | f    | 1989-05-13 | NULL  |
  14262.      +--------+--------+---------+------+------------+-------+
  14263.  
  14264. To find names containing a `w':
  14265.  
  14266.      mysql> SELECT * FROM pet WHERE name LIKE '%w%';
  14267.      +----------+-------+---------+------+------------+------------+
  14268.      | name     | owner | species | sex  | birth      | death      |
  14269.      +----------+-------+---------+------+------------+------------+
  14270.      | Claws    | Gwen  | cat     | m    | 1994-03-17 | NULL       |
  14271.      | Bowser   | Diane | dog     | m    | 1989-08-31 | 1995-07-29 |
  14272.      | Whistler | Gwen  | bird    | NULL | 1997-12-09 | NULL       |
  14273.      +----------+-------+---------+------+------------+------------+
  14274.  
  14275. To find names containing exactly five characters, use five instances of
  14276. the `_' pattern character:
  14277.  
  14278.      mysql> SELECT * FROM pet WHERE name LIKE '_____';
  14279.      +-------+--------+---------+------+------------+-------+
  14280.      | name  | owner  | species | sex  | birth      | death |
  14281.      +-------+--------+---------+------+------------+-------+
  14282.      | Claws | Gwen   | cat     | m    | 1994-03-17 | NULL  |
  14283.      | Buffy | Harold | dog     | f    | 1989-05-13 | NULL  |
  14284.      +-------+--------+---------+------+------------+-------+
  14285.  
  14286. The other type of pattern matching provided by MySQL uses extended
  14287. regular expressions.  When you test for a match for this type of
  14288. pattern, use the `REGEXP' and `NOT REGEXP' operators (or `RLIKE' and
  14289. `NOT RLIKE', which are synonyms).
  14290.  
  14291. Some characteristics of extended regular expressions are:
  14292.  
  14293.    * `.' matches any single character.
  14294.  
  14295.    * A character class `[...]' matches any character within the
  14296.      brackets.  For example, `[abc]' matches `a', `b', or `c'.  To name
  14297.      a range of characters, use a dash.  `[a-z]' matches any letter,
  14298.      whereas `[0-9]' matches any digit.
  14299.  
  14300.    * `*' matches zero or more instances of the thing preceding it.  For
  14301.      example, `x*' matches any number of `x' characters, `[0-9]*'
  14302.      matches any number of digits, and `.*' matches any number of
  14303.      anything.
  14304.  
  14305.    * A `REGEXP' pattern match succeed if the pattern matches anywhere
  14306.      in the value being tested.  (This differs from a `LIKE' pattern
  14307.      match, which succeeds only if the pattern matches the entire
  14308.      value.)
  14309.  
  14310.    * To anchor a pattern so that it must match the beginning or end of
  14311.      the value being tested, use `^' at the beginning or `$' at the end
  14312.      of the pattern.
  14313.  
  14314. To demonstrate how extended regular expressions work, the `LIKE' queries
  14315. shown previously are rewritten here to use `REGEXP'.
  14316.  
  14317. To find names beginning with `b', use `^' to match the beginning of the
  14318. name:
  14319.  
  14320.      mysql> SELECT * FROM pet WHERE name REGEXP '^b';
  14321.      +--------+--------+---------+------+------------+------------+
  14322.      | name   | owner  | species | sex  | birth      | death      |
  14323.      +--------+--------+---------+------+------------+------------+
  14324.      | Buffy  | Harold | dog     | f    | 1989-05-13 | NULL       |
  14325.      | Bowser | Diane  | dog     | m    | 1989-08-31 | 1995-07-29 |
  14326.      +--------+--------+---------+------+------------+------------+
  14327.  
  14328. Prior to MySQL Version 3.23.4, `REGEXP' is case sensitive, and the
  14329. previous query will return no rows. In this case, to match either
  14330. lowercase or uppercase `b', use this query instead:
  14331.  
  14332.      mysql> SELECT * FROM pet WHERE name REGEXP '^[bB]';
  14333.  
  14334. From MySQL 3.23.4 on, if you really want to force a `REGEXP' comparison
  14335. to be case sensitive, use the `BINARY' keyword to make one of the
  14336. strings a binary string. This query will match only lowercase `b' at
  14337. the beginning of a name:
  14338.  
  14339.      mysql> SELECT * FROM pet WHERE name REGEXP BINARY '^b';
  14340.  
  14341. To find names ending with `fy', use `$' to match the end of the name:
  14342.  
  14343.      mysql> SELECT * FROM pet WHERE name REGEXP 'fy$';
  14344.      +--------+--------+---------+------+------------+-------+
  14345.      | name   | owner  | species | sex  | birth      | death |
  14346.      +--------+--------+---------+------+------------+-------+
  14347.      | Fluffy | Harold | cat     | f    | 1993-02-04 | NULL  |
  14348.      | Buffy  | Harold | dog     | f    | 1989-05-13 | NULL  |
  14349.      +--------+--------+---------+------+------------+-------+
  14350.  
  14351. To find names containing a `w', use this query:
  14352.  
  14353.      mysql> SELECT * FROM pet WHERE name REGEXP 'w';
  14354.      +----------+-------+---------+------+------------+------------+
  14355.      | name     | owner | species | sex  | birth      | death      |
  14356.      +----------+-------+---------+------+------------+------------+
  14357.      | Claws    | Gwen  | cat     | m    | 1994-03-17 | NULL       |
  14358.      | Bowser   | Diane | dog     | m    | 1989-08-31 | 1995-07-29 |
  14359.      | Whistler | Gwen  | bird    | NULL | 1997-12-09 | NULL       |
  14360.      +----------+-------+---------+------+------------+------------+
  14361.  
  14362. Because a regular expression pattern matches if it occurs anywhere in
  14363. the value, it is not necessary in the previous query to put a wildcard
  14364. on either side of the pattern to get it to match the entire value like
  14365. it would be if you used an SQL pattern.
  14366.  
  14367. To find names containing exactly five characters, use `^' and `$' to
  14368. match the beginning and end of the name, and five instances of `.' in
  14369. between:
  14370.  
  14371.      mysql> SELECT * FROM pet WHERE name REGEXP '^.....$';
  14372.      +-------+--------+---------+------+------------+-------+
  14373.      | name  | owner  | species | sex  | birth      | death |
  14374.      +-------+--------+---------+------+------------+-------+
  14375.      | Claws | Gwen   | cat     | m    | 1994-03-17 | NULL  |
  14376.      | Buffy | Harold | dog     | f    | 1989-05-13 | NULL  |
  14377.      +-------+--------+---------+------+------------+-------+
  14378.  
  14379. You could also write the previous query using the `{n}'
  14380. "repeat-`n'-times" operator:
  14381.  
  14382.      mysql> SELECT * FROM pet WHERE name REGEXP '^.{5}$';
  14383.      +-------+--------+---------+------+------------+-------+
  14384.      | name  | owner  | species | sex  | birth      | death |
  14385.      +-------+--------+---------+------+------------+-------+
  14386.      | Claws | Gwen   | cat     | m    | 1994-03-17 | NULL  |
  14387.      | Buffy | Harold | dog     | f    | 1989-05-13 | NULL  |
  14388.      +-------+--------+---------+------+------------+-------+
  14389.  
  14390. Counting Rows
  14391. .............
  14392.  
  14393. Databases are often used to answer the question, "How often does a
  14394. certain type of data occur in a table?"  For example, you might want to
  14395. know how many pets you have, or how many pets each owner has, or you
  14396. might want to perform various kinds of census operations on your
  14397. animals.
  14398.  
  14399. Counting the total number of animals you have is the same question as
  14400. "How many rows are in the `pet' table?" because there is one record per
  14401. pet.  `COUNT(*)' counts the number of rows, so the query to count your
  14402. animals looks like this:
  14403.  
  14404.      mysql> SELECT COUNT(*) FROM pet;
  14405.      +----------+
  14406.      | COUNT(*) |
  14407.      +----------+
  14408.      |        9 |
  14409.      +----------+
  14410.  
  14411. Earlier, you retrieved the names of the people who owned pets.  You can
  14412. use `COUNT()' if you want to find out how many pets each owner has:
  14413.  
  14414.      mysql> SELECT owner, COUNT(*) FROM pet GROUP BY owner;
  14415.      +--------+----------+
  14416.      | owner  | COUNT(*) |
  14417.      +--------+----------+
  14418.      | Benny  |        2 |
  14419.      | Diane  |        2 |
  14420.      | Gwen   |        3 |
  14421.      | Harold |        2 |
  14422.      +--------+----------+
  14423.  
  14424. Note the use of `GROUP BY' to group together all records for each
  14425. `owner'.  Without it, all you get is an error message:
  14426.  
  14427.      mysql> SELECT owner, COUNT(*) FROM pet;
  14428.      ERROR 1140: Mixing of GROUP columns (MIN(),MAX(),COUNT()...)
  14429.      with no GROUP columns is illegal if there is no GROUP BY clause
  14430.  
  14431. `COUNT()' and `GROUP BY' are useful for characterizing your data in
  14432. various ways.  The following examples show different ways to perform
  14433. animal census operations.
  14434.  
  14435. Number of animals per species:
  14436.  
  14437.      mysql> SELECT species, COUNT(*) FROM pet GROUP BY species;
  14438.      +---------+----------+
  14439.      | species | COUNT(*) |
  14440.      +---------+----------+
  14441.      | bird    |        2 |
  14442.      | cat     |        2 |
  14443.      | dog     |        3 |
  14444.      | hamster |        1 |
  14445.      | snake   |        1 |
  14446.      +---------+----------+
  14447.  
  14448. Number of animals per sex:
  14449.  
  14450.      mysql> SELECT sex, COUNT(*) FROM pet GROUP BY sex;
  14451.      +------+----------+
  14452.      | sex  | COUNT(*) |
  14453.      +------+----------+
  14454.      | NULL |        1 |
  14455.      | f    |        4 |
  14456.      | m    |        4 |
  14457.      +------+----------+
  14458.  
  14459. (In this output, `NULL' indicates that the sex is unknown.)
  14460.  
  14461. Number of animals per combination of species and sex:
  14462.  
  14463.      mysql> SELECT species, sex, COUNT(*) FROM pet GROUP BY species, sex;
  14464.      +---------+------+----------+
  14465.      | species | sex  | COUNT(*) |
  14466.      +---------+------+----------+
  14467.      | bird    | NULL |        1 |
  14468.      | bird    | f    |        1 |
  14469.      | cat     | f    |        1 |
  14470.      | cat     | m    |        1 |
  14471.      | dog     | f    |        1 |
  14472.      | dog     | m    |        2 |
  14473.      | hamster | f    |        1 |
  14474.      | snake   | m    |        1 |
  14475.      +---------+------+----------+
  14476.  
  14477. You need not retrieve an entire table when you use `COUNT()'.  For
  14478. example, the previous query, when performed just on dogs and cats,
  14479. looks like this:
  14480.  
  14481.      mysql> SELECT species, sex, COUNT(*) FROM pet
  14482.          -> WHERE species = 'dog' OR species = 'cat'
  14483.          -> GROUP BY species, sex;
  14484.      +---------+------+----------+
  14485.      | species | sex  | COUNT(*) |
  14486.      +---------+------+----------+
  14487.      | cat     | f    |        1 |
  14488.      | cat     | m    |        1 |
  14489.      | dog     | f    |        1 |
  14490.      | dog     | m    |        2 |
  14491.      +---------+------+----------+
  14492.  
  14493. Or, if you wanted the number of animals per sex only for known-sex
  14494. animals:
  14495.  
  14496.      mysql> SELECT species, sex, COUNT(*) FROM pet
  14497.          -> WHERE sex IS NOT NULL
  14498.          -> GROUP BY species, sex;
  14499.      +---------+------+----------+
  14500.      | species | sex  | COUNT(*) |
  14501.      +---------+------+----------+
  14502.      | bird    | f    |        1 |
  14503.      | cat     | f    |        1 |
  14504.      | cat     | m    |        1 |
  14505.      | dog     | f    |        1 |
  14506.      | dog     | m    |        2 |
  14507.      | hamster | f    |        1 |
  14508.      | snake   | m    |        1 |
  14509.      +---------+------+----------+
  14510.  
  14511. Using More Than one Table
  14512. .........................
  14513.  
  14514. The `pet' table keeps track of which pets you have.  If you want to
  14515. record other information about them, such as events in their lives like
  14516. visits to the vet or when litters are born, you need another table.
  14517. What should this table look like? It needs:
  14518.  
  14519.    * To contain the pet name so you know which animal each event
  14520.      pertains to.
  14521.  
  14522.    * A date so you know when the event occurred.
  14523.  
  14524.    * A field to describe the event.
  14525.  
  14526.    * An event type field, if you want to be able to categorize events.
  14527.  
  14528. Given these considerations, the `CREATE TABLE' statement for the
  14529. `event' table might look like this:
  14530.  
  14531.      mysql> CREATE TABLE event (name VARCHAR(20), date DATE,
  14532.          -> type VARCHAR(15), remark VARCHAR(255));
  14533.  
  14534. As with the `pet' table, it's easiest to load the initial records by
  14535. creating a tab-delimited text file containing the information:
  14536.  
  14537. *name*      *date*      *type*      *remark*
  14538. Fluffy      1995-05-15  litter      4 kittens, 3 female, 1
  14539.                                     male
  14540. Buffy       1993-06-23  litter      5 puppies, 2 female, 3
  14541.                                     male
  14542. Buffy       1994-06-19  litter      3 puppies, 3 female
  14543. Chirpy      1999-03-21  vet         needed beak straightened
  14544. Slim        1997-08-03  vet         broken rib
  14545. Bowser      1991-10-12  kennel      
  14546. Fang        1991-10-12  kennel      
  14547. Fang        1998-08-28  birthday    Gave him a new chew toy
  14548. Claws       1998-03-17  birthday    Gave him a new flea
  14549.                                     collar
  14550. Whistler    1998-12-09  birthday    First birthday
  14551.  
  14552. Load the records like this:
  14553.  
  14554.      mysql> LOAD DATA LOCAL INFILE 'event.txt' INTO TABLE event;
  14555.  
  14556. Based on what you've learned from the queries you've run on the `pet'
  14557. table, you should be able to perform retrievals on the records in the
  14558. `event' table; the principles are the same.  But when is the `event'
  14559. table by itself insufficient to answer questions you might ask?
  14560.  
  14561. Suppose that you want to find out the ages at which each pet had its
  14562. litters. We saw earlier how to calculate ages from two dates.  The
  14563. litter date of the mother is in the `event' table, but to calculate her
  14564. age on that date you need her birth date, which is stored in the `pet'
  14565. table.  This means the query requires both tables:
  14566.  
  14567.      mysql> SELECT pet.name,
  14568.          -> (YEAR(date)-YEAR(birth)) - (RIGHT(date,5)<RIGHT(birth,5)) AS age,
  14569.          -> remark
  14570.          -> FROM pet, event
  14571.          -> WHERE pet.name = event.name AND type = 'litter';
  14572.      +--------+------+-----------------------------+
  14573.      | name   | age  | remark                      |
  14574.      +--------+------+-----------------------------+
  14575.      | Fluffy |    2 | 4 kittens, 3 female, 1 male |
  14576.      | Buffy  |    4 | 5 puppies, 2 female, 3 male |
  14577.      | Buffy  |    5 | 3 puppies, 3 female         |
  14578.      +--------+------+-----------------------------+
  14579.  
  14580. There are several things to note about this query:
  14581.  
  14582.    * The `FROM' clause lists two tables because the query needs to pull
  14583.      information from both of them.
  14584.  
  14585.    * When combining (joining) information from multiple tables, you
  14586.      need to specify how records in one table can be matched to records
  14587.      in the other.  This is easy because they both have a `name'
  14588.      column.  The query uses `WHERE' clause to match up records in the
  14589.      two tables based on the `name' values.
  14590.  
  14591.    * Because the `name' column occurs in both tables, you must be
  14592.      specific about which table you mean when referring to the column.
  14593.      This is done by prepending the table name to the column name.
  14594.  
  14595. You need not have two different tables to perform a join.  Sometimes it
  14596. is useful to join a table to itself, if you want to compare records in
  14597. a table to other records in that same table.  For example, to find
  14598. breeding pairs among your pets, you can join the `pet' table with
  14599. itself to produce candidate pairs of males and females of like species:
  14600.  
  14601.      mysql> SELECT p1.name, p1.sex, p2.name, p2.sex, p1.species
  14602.          -> FROM pet AS p1, pet AS p2
  14603.          -> WHERE p1.species = p2.species AND p1.sex = 'f' AND p2.sex = 'm';
  14604.      +--------+------+--------+------+---------+
  14605.      | name   | sex  | name   | sex  | species |
  14606.      +--------+------+--------+------+---------+
  14607.      | Fluffy | f    | Claws  | m    | cat     |
  14608.      | Buffy  | f    | Fang   | m    | dog     |
  14609.      | Buffy  | f    | Bowser | m    | dog     |
  14610.      +--------+------+--------+------+---------+
  14611.  
  14612. In this query, we specify aliases for the table name in order to refer
  14613. to the columns and keep straight which instance of the table each
  14614. column reference is associated with.
  14615.  
  14616. Getting Information About Databases and Tables
  14617. ==============================================
  14618.  
  14619. What if you forget the name of a database or table, or what the
  14620. structure of a given table is (for example, what its columns are
  14621. called)?  MySQL addresses this problem through several statements that
  14622. provide information about the databases and tables it supports.
  14623.  
  14624. You have already seen `SHOW DATABASES', which lists the databases
  14625. managed by the server.  To find out which database is currently
  14626. selected, use the `DATABASE()' function:
  14627.  
  14628.      mysql> SELECT DATABASE();
  14629.      +------------+
  14630.      | DATABASE() |
  14631.      +------------+
  14632.      | menagerie  |
  14633.      +------------+
  14634.  
  14635. If you haven't selected any database yet, the result is `NULL' (or the
  14636. empty string before MySQL 4.1.1).
  14637.  
  14638. To find out what tables the current database contains (for example, when
  14639. you're not sure about the name of a table), use this command:
  14640.  
  14641.      mysql> SHOW TABLES;
  14642.      +---------------------+
  14643.      | Tables in menagerie |
  14644.      +---------------------+
  14645.      | event               |
  14646.      | pet                 |
  14647.      +---------------------+
  14648.  
  14649. If you want to find out about the structure of a table, the `DESCRIBE'
  14650. command is useful; it displays information about each of a table's
  14651. columns:
  14652.  
  14653.      mysql> DESCRIBE pet;
  14654.      +---------+-------------+------+-----+---------+-------+
  14655.      | Field   | Type        | Null | Key | Default | Extra |
  14656.      +---------+-------------+------+-----+---------+-------+
  14657.      | name    | varchar(20) | YES  |     | NULL    |       |
  14658.      | owner   | varchar(20) | YES  |     | NULL    |       |
  14659.      | species | varchar(20) | YES  |     | NULL    |       |
  14660.      | sex     | char(1)     | YES  |     | NULL    |       |
  14661.      | birth   | date        | YES  |     | NULL    |       |
  14662.      | death   | date        | YES  |     | NULL    |       |
  14663.      +---------+-------------+------+-----+---------+-------+
  14664.  
  14665. `Field' indicates the column name, `Type' is the data type for the
  14666. column, `NULL' indicates whether the column can contain `NULL' values,
  14667. `Key' indicates whether the column is indexed, and `Default' specifies
  14668. the column's default value.
  14669.  
  14670. If you have indexes on a table, `SHOW INDEX FROM TBL_NAME' produces
  14671. information about them.
  14672.  
  14673. Using `mysql' in Batch Mode
  14674. ===========================
  14675.  
  14676. In the previous sections, you used `mysql' interactively to enter
  14677. queries and view the results.  You can also run `mysql' in batch mode.
  14678. To do this, put the commands you want to run in a file, then tell
  14679. `mysql' to read its input from the file:
  14680.  
  14681.      shell> mysql < BATCH-FILE
  14682.  
  14683. If you are running `mysql' under Windows and have some special
  14684. characters in the file that cause problems, you can do this:
  14685.  
  14686.      C:\> mysql -e "source BATCH-FILE"
  14687.  
  14688. If you need to specify connection parameters on the command line, the
  14689. command might look like this:
  14690.  
  14691.      shell> mysql -h HOST -u USER -p < BATCH-FILE
  14692.      Enter password: ********
  14693.  
  14694. When you use `mysql' this way, you are creating a script file, then
  14695. executing the script.
  14696.  
  14697. If you want the script to continue even if some of the statements in it
  14698. produce errors, you should use the `--force' command-line option.
  14699.  
  14700. Why use a script?  Here are a few reasons:
  14701.  
  14702.    * If you run a query repeatedly (say, every day or every week),
  14703.      making it a script allows you to avoid retyping it each time you
  14704.      execute it.
  14705.  
  14706.    * You can generate new queries from existing ones that are similar
  14707.      by copying and editing script files.
  14708.  
  14709.    * Batch mode can also be useful while you're developing a query,
  14710.      particularly for multiple-line commands or multiple-statement
  14711.      sequences of commands.  If you make a mistake, you don't have to
  14712.      retype everything.  Just edit your script to correct the error,
  14713.      then tell `mysql' to execute it again.
  14714.  
  14715.    * If you have a query that produces a lot of output, you can run the
  14716.      output through a pager rather than watching it scroll off the top
  14717.      of your screen:
  14718.  
  14719.           shell> mysql < BATCH-FILE | more
  14720.  
  14721.    * You can catch the output in a file for further processing:
  14722.  
  14723.           shell> mysql < BATCH-FILE > mysql.out
  14724.  
  14725.    * You can distribute your script to other people so they can run the
  14726.      commands, too.
  14727.  
  14728.    * Some situations do not allow for interactive use, for example,
  14729.      when you run a query from a `cron' job.  In this case, you must
  14730.      use batch mode.
  14731.  
  14732. The default output format is different (more concise) when you run
  14733. `mysql' in batch mode than when you use it interactively.  For example,
  14734. the output of `SELECT DISTINCT species FROM pet' looks like this when
  14735. `mysql' is run interactively:
  14736.  
  14737.      +---------+
  14738.      | species |
  14739.      +---------+
  14740.      | bird    |
  14741.      | cat     |
  14742.      | dog     |
  14743.      | hamster |
  14744.      | snake   |
  14745.      +---------+
  14746.  
  14747. In batch mode, the output looks like this instead:
  14748.  
  14749.      species
  14750.      bird
  14751.      cat
  14752.      dog
  14753.      hamster
  14754.      snake
  14755.  
  14756. If you want to get the interactive output format in batch mode, use
  14757. `mysql -t'.  To echo to the output the commands that are executed, use
  14758. `mysql -vvv'.
  14759.  
  14760. You can also use scripts from the `mysql' prompt by using the `source'
  14761. or `\.' command:
  14762.  
  14763.      mysql> source filename;
  14764.      mysql> \. filename
  14765.  
  14766. Examples of Common Queries
  14767. ==========================
  14768.  
  14769. Here are examples of how to solve some common problems with MySQL.
  14770.  
  14771. Some of the examples use the table `shop' to hold the price of each
  14772. article (item number) for certain traders (dealers).  Supposing that
  14773. each trader has a single fixed price per article, then (`article',
  14774. `dealer') is a primary key for the records.
  14775.  
  14776. Start the command-line tool `mysql' and select a database:
  14777.  
  14778.      shell> mysql your-database-name
  14779.  
  14780. (In most MySQL installations, you can use the database name `test').
  14781.  
  14782. You can create and populate the example table with these statements:
  14783.  
  14784.      mysql> CREATE TABLE shop (
  14785.          -> article INT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL,
  14786.          -> dealer  CHAR(20)                 DEFAULT ''     NOT NULL,
  14787.          -> price   DOUBLE(16,2)             DEFAULT '0.00' NOT NULL,
  14788.          -> PRIMARY KEY(article, dealer));
  14789.      mysql> INSERT INTO shop VALUES
  14790.          -> (1,'A',3.45),(1,'B',3.99),(2,'A',10.99),(3,'B',1.45),
  14791.          -> (3,'C',1.69),(3,'D',1.25),(4,'D',19.95);
  14792.  
  14793. After issuing the statements, the table should have the following
  14794. contents:
  14795.  
  14796.      mysql> SELECT * FROM shop;
  14797.      +---------+--------+-------+
  14798.      | article | dealer | price |
  14799.      +---------+--------+-------+
  14800.      |    0001 | A      |  3.45 |
  14801.      |    0001 | B      |  3.99 |
  14802.      |    0002 | A      | 10.99 |
  14803.      |    0003 | B      |  1.45 |
  14804.      |    0003 | C      |  1.69 |
  14805.      |    0003 | D      |  1.25 |
  14806.      |    0004 | D      | 19.95 |
  14807.      +---------+--------+-------+
  14808.  
  14809. The Maximum Value for a Column
  14810. ------------------------------
  14811.  
  14812. "What's the highest item number?"
  14813.  
  14814.      SELECT MAX(article) AS article FROM shop;
  14815.      
  14816.      +---------+
  14817.      | article |
  14818.      +---------+
  14819.      |       4 |
  14820.      +---------+
  14821.  
  14822. The Row Holding the Maximum of a Certain Column
  14823. -----------------------------------------------
  14824.  
  14825. "Find number, dealer, and price of the most expensive article."
  14826.  
  14827. In standard SQL (and as of MySQL 4.1), this is easily done with a
  14828. subquery:
  14829.  
  14830.      SELECT article, dealer, price
  14831.      FROM   shop
  14832.      WHERE  price=(SELECT MAX(price) FROM shop);
  14833.  
  14834. In MySQL versions prior to 4.1, just do it in two steps:
  14835.  
  14836.   1. Get the maximum price value from the table with a `SELECT'
  14837.      statement.
  14838.           mysql> SELECT MAX(price) FROM shop;
  14839.           +------------+
  14840.           | MAX(price) |
  14841.           +------------+
  14842.           |      19.95 |
  14843.           +------------+
  14844.  
  14845.   2. Using the value 19.95 shown by the previous query to be the maximum
  14846.      article price, write a query to locate and display the
  14847.      corresponding record:
  14848.           mysql> SELECT article, dealer, price
  14849.               -> FROM   shop
  14850.               -> WHERE  price=19.95;
  14851.           +---------+--------+-------+
  14852.           | article | dealer | price |
  14853.           +---------+--------+-------+
  14854.           |    0004 | D      | 19.95 |
  14855.           +---------+--------+-------+
  14856.  
  14857. Another solution is to sort all rows descending by price and only get
  14858. the first row using the MySQL-specific `LIMIT' clause:
  14859.  
  14860.      SELECT article, dealer, price
  14861.      FROM   shop
  14862.      ORDER BY price DESC
  14863.      LIMIT 1;
  14864.  
  14865. Note:  If there were several most expensive articles, each with a price
  14866. of 19.95, the `LIMIT' solution would show only one of them!
  14867.  
  14868. Maximum of Column per Group
  14869. ---------------------------
  14870.  
  14871. "What's the highest price per article?"
  14872.  
  14873.      SELECT article, MAX(price) AS price
  14874.      FROM   shop
  14875.      GROUP BY article
  14876.      
  14877.      +---------+-------+
  14878.      | article | price |
  14879.      +---------+-------+
  14880.      |    0001 |  3.99 |
  14881.      |    0002 | 10.99 |
  14882.      |    0003 |  1.69 |
  14883.      |    0004 | 19.95 |
  14884.      +---------+-------+
  14885.  
  14886. The Rows Holding the Group-wise Maximum of a Certain Field
  14887. ----------------------------------------------------------
  14888.  
  14889. "For each article, find the dealer or dealers with the most expensive
  14890. price."
  14891.  
  14892. In standard SQL (and as of MySQL 4.1), the problem can be solved with a
  14893. subquery like this:
  14894.  
  14895.      SELECT article, dealer, price
  14896.      FROM   shop s1
  14897.      WHERE  price=(SELECT MAX(s2.price)
  14898.                    FROM shop s2
  14899.                    WHERE s1.article = s2.article);
  14900.  
  14901. In MySQL versions prior to 4.1, it's best do it in several steps:
  14902.  
  14903.   1. Get the list of (article,maxprice) pairs.
  14904.  
  14905.   2. For each article, get the corresponding rows that have the stored
  14906.      maximum price.
  14907.  
  14908. This can easily be done with a temporary table and a join:
  14909.  
  14910.      CREATE TEMPORARY TABLE tmp (
  14911.              article INT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL,
  14912.              price   DOUBLE(16,2)             DEFAULT '0.00' NOT NULL);
  14913.      
  14914.      LOCK TABLES shop READ;
  14915.      
  14916.      INSERT INTO tmp SELECT article, MAX(price) FROM shop GROUP BY article;
  14917.      
  14918.      SELECT shop.article, dealer, shop.price FROM shop, tmp
  14919.      WHERE shop.article=tmp.article AND shop.price=tmp.price;
  14920.      
  14921.      UNLOCK TABLES;
  14922.      
  14923.      DROP TABLE tmp;
  14924.  
  14925. If you don't use a `TEMPORARY' table, you must also lock the `tmp'
  14926. table.
  14927.  
  14928. "Can it be done with a single query?"
  14929.  
  14930. Yes, but only by using a quite inefficient trick called the "MAX-CONCAT
  14931. trick":
  14932.  
  14933.      SELECT article,
  14934.             SUBSTRING( MAX( CONCAT(LPAD(price,6,'0'),dealer) ), 7) AS dealer,
  14935.        0.00+LEFT(      MAX( CONCAT(LPAD(price,6,'0'),dealer) ), 6) AS price
  14936.      FROM   shop
  14937.      GROUP BY article;
  14938.      
  14939.      +---------+--------+-------+
  14940.      | article | dealer | price |
  14941.      +---------+--------+-------+
  14942.      |    0001 | B      |  3.99 |
  14943.      |    0002 | A      | 10.99 |
  14944.      |    0003 | C      |  1.69 |
  14945.      |    0004 | D      | 19.95 |
  14946.      +---------+--------+-------+
  14947.  
  14948. The last example can be made a bit more efficient by doing the
  14949. splitting of the concatenated column in the client.
  14950.  
  14951. Using User Variables
  14952. --------------------
  14953.  
  14954. You can use MySQL user variables to remember results without having to
  14955. store them in temporary variables in the client.  *Note Variables::.
  14956.  
  14957. For example, to find the articles with the highest and lowest price you
  14958. can do this:
  14959.  
  14960.      mysql> SELECT @min_price:=MIN(price),@max_price:=MAX(price) FROM shop;
  14961.      mysql> SELECT * FROM shop WHERE price=@min_price OR price=@max_price;
  14962.      +---------+--------+-------+
  14963.      | article | dealer | price |
  14964.      +---------+--------+-------+
  14965.      |    0003 | D      |  1.25 |
  14966.      |    0004 | D      | 19.95 |
  14967.      +---------+--------+-------+
  14968.  
  14969. Using Foreign Keys
  14970. ------------------
  14971.  
  14972. In MySQL 3.23.44 and up, `InnoDB' tables support checking of foreign
  14973. key constraints. *Note `InnoDB': InnoDB.  See also *Note ANSI diff
  14974. Foreign Keys::.
  14975.  
  14976. You don't actually need foreign keys to join two tables.  For table
  14977. types other than `InnoDB', the only things MySQL currently doesn't do
  14978. are 1) `CHECK' to make sure that the keys you use really exist in the
  14979. table or tables you're referencing and 2) automatically delete rows
  14980. from a table with a foreign key definition. Using your keys to join
  14981. tables will work just fine:
  14982.  
  14983.      CREATE TABLE person (
  14984.          id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
  14985.          name CHAR(60) NOT NULL,
  14986.          PRIMARY KEY (id)
  14987.      );
  14988.      
  14989.      CREATE TABLE shirt (
  14990.          id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
  14991.          style ENUM('t-shirt', 'polo', 'dress') NOT NULL,
  14992.          color ENUM('red', 'blue', 'orange', 'white', 'black') NOT NULL,
  14993.          owner SMALLINT UNSIGNED NOT NULL REFERENCES person(id),
  14994.          PRIMARY KEY (id)
  14995.      );
  14996.      
  14997.      
  14998.      INSERT INTO person VALUES (NULL, 'Antonio Paz');
  14999.      
  15000.      INSERT INTO shirt VALUES
  15001.      (NULL, 'polo', 'blue', LAST_INSERT_ID()),
  15002.      (NULL, 'dress', 'white', LAST_INSERT_ID()),
  15003.      (NULL, 't-shirt', 'blue', LAST_INSERT_ID());
  15004.      
  15005.      
  15006.      INSERT INTO person VALUES (NULL, 'Lilliana Angelovska');
  15007.      
  15008.      INSERT INTO shirt VALUES
  15009.      (NULL, 'dress', 'orange', LAST_INSERT_ID()),
  15010.      (NULL, 'polo', 'red', LAST_INSERT_ID()),
  15011.      (NULL, 'dress', 'blue', LAST_INSERT_ID()),
  15012.      (NULL, 't-shirt', 'white', LAST_INSERT_ID());
  15013.      
  15014.      
  15015.      SELECT * FROM person;
  15016.      +----+---------------------+
  15017.      | id | name                |
  15018.      +----+---------------------+
  15019.      |  1 | Antonio Paz         |
  15020.      |  2 | Lilliana Angelovska |
  15021.      +----+---------------------+
  15022.      
  15023.      SELECT * FROM shirt;
  15024.      +----+---------+--------+-------+
  15025.      | id | style   | color  | owner |
  15026.      +----+---------+--------+-------+
  15027.      |  1 | polo    | blue   |     1 |
  15028.      |  2 | dress   | white  |     1 |
  15029.      |  3 | t-shirt | blue   |     1 |
  15030.      |  4 | dress   | orange |     2 |
  15031.      |  5 | polo    | red    |     2 |
  15032.      |  6 | dress   | blue   |     2 |
  15033.      |  7 | t-shirt | white  |     2 |
  15034.      +----+---------+--------+-------+
  15035.      
  15036.      
  15037.      SELECT s.* FROM person p, shirt s
  15038.       WHERE p.name LIKE 'Lilliana%'
  15039.         AND s.owner = p.id
  15040.         AND s.color <> 'white';
  15041.      
  15042.      +----+-------+--------+-------+
  15043.      | id | style | color  | owner |
  15044.      +----+-------+--------+-------+
  15045.      |  4 | dress | orange |     2 |
  15046.      |  5 | polo  | red    |     2 |
  15047.      |  6 | dress | blue   |     2 |
  15048.      +----+-------+--------+-------+
  15049.  
  15050. Searching on Two Keys
  15051. ---------------------
  15052.  
  15053. MySQL doesn't yet optimize when you search on two different keys
  15054. combined with `OR' (searching on one key with different `OR' parts is
  15055. optimized quite well):
  15056.  
  15057.      SELECT field1_index, field2_index FROM test_table
  15058.      WHERE field1_index = '1' OR  field2_index = '1'
  15059.  
  15060. The reason is that we haven't yet had time to come up with an efficient
  15061. way to handle this in the general case. (The `AND' handling is, in
  15062. comparison, now completely general and works very well.)
  15063.  
  15064. In MySQL 4.0 and up, you can solve this problem efficiently by using a
  15065. `UNION' that combines the output of two separate `SELECT' statements.
  15066. *Note UNION::.  Each `SELECT' searches only one key and can be
  15067. optimized:
  15068.  
  15069.      SELECT field1_index, field2_index
  15070.          FROM test_table WHERE field1_index = '1'
  15071.      UNION
  15072.      SELECT field1_index, field2_index
  15073.          FROM test_table WHERE field2_index = '1';
  15074.  
  15075. Prior to MySQL 4.0, you can achieve the same effect by using a
  15076. `TEMPORARY' table and separate `SELECT' statements.  This type of
  15077. optimization is also very good if you are using very complicated
  15078. queries where the SQL server does the optimizations in the wrong order.
  15079.  
  15080.      CREATE TEMPORARY TABLE tmp
  15081.      SELECT field1_index, field2_index
  15082.          FROM test_table WHERE field1_index = '1';
  15083.      INSERT INTO tmp
  15084.      SELECT field1_index, field2_index
  15085.          FROM test_table WHERE field2_index = '1';
  15086.      SELECT * from tmp;
  15087.      DROP TABLE tmp;
  15088.  
  15089. This method of solving the problem is in effect a `UNION' of two
  15090. queries.
  15091.  
  15092. Calculating Visits Per Day
  15093. --------------------------
  15094.  
  15095. The following example shows how you can use the bit group functions to
  15096. calculate the number of days per month a user has visited a Web page.
  15097.  
  15098.      CREATE TABLE t1 (year YEAR(4), month INT(2) UNSIGNED ZEROFILL,
  15099.                   day INT(2) UNSIGNED ZEROFILL);
  15100.      INSERT INTO t1 VALUES(2000,1,1),(2000,1,20),(2000,1,30),(2000,2,2),
  15101.                  (2000,2,23),(2000,2,23);
  15102.  
  15103. The example table contains year-month-day values representing visits by
  15104. users to the page. To determine how many different days in each month
  15105. these visits occur, use this query:
  15106.  
  15107.      SELECT year,month,BIT_COUNT(BIT_OR(1<<day)) AS days FROM t1
  15108.             GROUP BY year,month;
  15109.  
  15110. Which returns:
  15111.  
  15112.      +------+-------+------+
  15113.      | year | month | days |
  15114.      +------+-------+------+
  15115.      | 2000 |    01 |    3 |
  15116.      | 2000 |    02 |    2 |
  15117.      +------+-------+------+
  15118.  
  15119. The query calculates how many different days appear in the table for
  15120. each year/month combination, with automatic removal of duplicate
  15121. entries.
  15122.  
  15123. Using `AUTO_INCREMENT'
  15124. ----------------------
  15125.  
  15126. The `AUTO_INCREMENT' attribute can be used to generate a unique
  15127. identity for new rows:
  15128.  
  15129.      CREATE TABLE animals (
  15130.                   id MEDIUMINT NOT NULL AUTO_INCREMENT,
  15131.                   name CHAR(30) NOT NULL,
  15132.                   PRIMARY KEY (id)
  15133.                   );
  15134.      INSERT INTO animals (name) VALUES ('dog'),('cat'),('penguin'),
  15135.                                        ('lax'),('whale'),('ostrich');
  15136.      SELECT * FROM animals;
  15137.  
  15138. Which returns:
  15139.  
  15140.      +----+---------+
  15141.      | id | name    |
  15142.      +----+---------+
  15143.      |  1 | dog     |
  15144.      |  2 | cat     |
  15145.      |  3 | penguin |
  15146.      |  4 | lax     |
  15147.      |  5 | whale   |
  15148.      |  6 | ostrich |
  15149.      +----+---------+
  15150.  
  15151. You can retrieve the most recent `AUTO_INCREMENT' value with the
  15152. `LAST_INSERT_ID()' SQL function or the `mysql_insert_id()' C API
  15153. function. These functions are connection-specific, so their return value
  15154. is not affected by another connection also doing inserts.
  15155.  
  15156. Note: For a multiple-row insert, `LAST_INSERT_ID()'/`mysql_insert_id()'
  15157. will actually return the `AUTO_INCREMENT' key from the *first* of the
  15158. inserted rows.  This allows multiple-row inserts to be reproduced
  15159. correctly on other servers in a replication setup.
  15160.  
  15161. For `MyISAM' and `BDB' tables you can specify `AUTO_INCREMENT' on a
  15162. secondary column in a multiple-column index.  In this case, the
  15163. generated value for the `AUTO_INCREMENT' column is calculated as
  15164. `MAX(auto_increment_column)+1 WHERE prefix=given-prefix'.  This is
  15165. useful when you want to put data into ordered groups.
  15166.  
  15167.      CREATE TABLE animals (
  15168.                   grp ENUM('fish','mammal','bird') NOT NULL,
  15169.                   id MEDIUMINT NOT NULL AUTO_INCREMENT,
  15170.                   name CHAR(30) NOT NULL,
  15171.                   PRIMARY KEY (grp,id)
  15172.                   );
  15173.      INSERT INTO animals (grp,name) VALUES('mammal','dog'),('mammal','cat'),
  15174.                        ('bird','penguin'),('fish','lax'),('mammal','whale'),
  15175.                        ('bird','ostrich');
  15176.      SELECT * FROM animals ORDER BY grp,id;
  15177.  
  15178. Which returns:
  15179.  
  15180.      +--------+----+---------+
  15181.      | grp    | id | name    |
  15182.      +--------+----+---------+
  15183.      | fish   |  1 | lax     |
  15184.      | mammal |  1 | dog     |
  15185.      | mammal |  2 | cat     |
  15186.      | mammal |  3 | whale   |
  15187.      | bird   |  1 | penguin |
  15188.      | bird   |  2 | ostrich |
  15189.      +--------+----+---------+
  15190.  
  15191. Note that in this case (when the `AUTO_INCREMENT' column is part of a
  15192. multiple-column index), `AUTO_INCREMENT' values will be reused if you
  15193. delete the row with the biggest `AUTO_INCREMENT' value in any group.
  15194. This happens even for `MyISAM' tables, for which `AUTO_INCREMENT'
  15195. values normally are not reused.)
  15196.  
  15197. Queries from the Twin Project
  15198. =============================
  15199.  
  15200. At Analytikerna and Lentus, we have been doing the systems and field
  15201. work for a big research project. This project is a collaboration
  15202. between the Institute of Environmental Medicine at Karolinska
  15203. Institutet Stockholm and the Section on Clinical Research in Aging and
  15204. Psychology at the University of Southern California.
  15205.  
  15206. The project involves a screening part where all twins in Sweden older
  15207. than 65 years are interviewed by telephone. Twins who meet certain
  15208. criteria are passed on to the next stage. In this latter stage, twins
  15209. who want to participate are visited by a doctor/nurse team. Some of the
  15210. examinations include physical and neuropsychological examination,
  15211. laboratory testing, neuroimaging, psychological status assessment, and
  15212. family history collection. In addition, data are collected on medical
  15213. and environmental risk factors.
  15214.  
  15215. More information about Twin studies can be found at:
  15216. `http://www.mep.ki.se/twinreg/index_en.html'
  15217.  
  15218. The latter part of the project is administered with a Web interface
  15219. written using Perl and MySQL.
  15220.  
  15221. Each night all data from the interviews is moved into a MySQL database.
  15222.  
  15223. Find All Non-distributed Twins
  15224. ------------------------------
  15225.  
  15226. The following query is used to determine who goes into the second part
  15227. of the project:
  15228.  
  15229.      SELECT
  15230.          CONCAT(p1.id, p1.tvab) + 0 AS tvid,
  15231.          CONCAT(p1.christian_name, ' ', p1.surname) AS Name,
  15232.          p1.postal_code AS Code,
  15233.          p1.city AS City,
  15234.          pg.abrev AS Area,
  15235.          IF(td.participation = 'Aborted', 'A', ' ') AS A,
  15236.          p1.dead AS dead1,
  15237.          l.event AS event1,
  15238.          td.suspect AS tsuspect1,
  15239.          id.suspect AS isuspect1,
  15240.          td.severe AS tsevere1,
  15241.          id.severe AS isevere1,
  15242.          p2.dead AS dead2,
  15243.          l2.event AS event2,
  15244.          h2.nurse AS nurse2,
  15245.          h2.doctor AS doctor2,
  15246.          td2.suspect AS tsuspect2,
  15247.          id2.suspect AS isuspect2,
  15248.          td2.severe AS tsevere2,
  15249.          id2.severe AS isevere2,
  15250.          l.finish_date
  15251.      FROM
  15252.          twin_project AS tp
  15253.          /* For Twin 1 */
  15254.          LEFT JOIN twin_data AS td ON tp.id = td.id
  15255.                    AND tp.tvab = td.tvab
  15256.          LEFT JOIN informant_data AS id ON tp.id = id.id
  15257.                    AND tp.tvab = id.tvab
  15258.          LEFT JOIN harmony AS h ON tp.id = h.id
  15259.                    AND tp.tvab = h.tvab
  15260.          LEFT JOIN lentus AS l ON tp.id = l.id
  15261.                    AND tp.tvab = l.tvab
  15262.          /* For Twin 2 */
  15263.          LEFT JOIN twin_data AS td2 ON p2.id = td2.id
  15264.                    AND p2.tvab = td2.tvab
  15265.          LEFT JOIN informant_data AS id2 ON p2.id = id2.id
  15266.                    AND p2.tvab = id2.tvab
  15267.          LEFT JOIN harmony AS h2 ON p2.id = h2.id
  15268.                    AND p2.tvab = h2.tvab
  15269.          LEFT JOIN lentus AS l2 ON p2.id = l2.id
  15270.                    AND p2.tvab = l2.tvab,
  15271.          person_data AS p1,
  15272.          person_data AS p2,
  15273.          postal_groups AS pg
  15274.      WHERE
  15275.          /* p1 gets main twin and p2 gets his/her twin. */
  15276.          /* ptvab is a field inverted from tvab */
  15277.          p1.id = tp.id AND p1.tvab = tp.tvab AND
  15278.          p2.id = p1.id AND p2.ptvab = p1.tvab AND
  15279.          /* Just the sceening survey */
  15280.          tp.survey_no = 5 AND
  15281.          /* Skip if partner died before 65 but allow emigration (dead=9) */
  15282.          (p2.dead = 0 OR p2.dead = 9 OR
  15283.           (p2.dead = 1 AND
  15284.            (p2.death_date = 0 OR
  15285.             (((TO_DAYS(p2.death_date) - TO_DAYS(p2.birthday)) / 365)
  15286.              >= 65))))
  15287.          AND
  15288.          (
  15289.          /* Twin is suspect */
  15290.          (td.future_contact = 'Yes' AND td.suspect = 2) OR
  15291.          /* Twin is suspect - Informant is Blessed */
  15292.          (td.future_contact = 'Yes' AND td.suspect = 1
  15293.                                     AND id.suspect = 1) OR
  15294.          /* No twin - Informant is Blessed */
  15295.          (ISNULL(td.suspect) AND id.suspect = 1
  15296.                              AND id.future_contact = 'Yes') OR
  15297.          /* Twin broken off - Informant is Blessed */
  15298.          (td.participation = 'Aborted'
  15299.           AND id.suspect = 1 AND id.future_contact = 'Yes') OR
  15300.          /* Twin broken off - No inform - Have partner */
  15301.          (td.participation = 'Aborted' AND ISNULL(id.suspect)
  15302.                                        AND p2.dead = 0))
  15303.          AND
  15304.          l.event = 'Finished'
  15305.          /* Get at area code */
  15306.          AND SUBSTRING(p1.postal_code, 1, 2) = pg.code
  15307.          /* Not already distributed */
  15308.          AND (h.nurse IS NULL OR h.nurse=00 OR h.doctor=00)
  15309.          /* Has not refused or been aborted */
  15310.          AND NOT (h.status = 'Refused' OR h.status = 'Aborted'
  15311.          OR h.status = 'Died' OR h.status = 'Other')
  15312.      ORDER BY
  15313.          tvid;
  15314.  
  15315. Some explanations:
  15316. `CONCAT(p1.id, p1.tvab) + 0 AS tvid'
  15317.      We want to sort on the concatenated `id' and `tvab' in numerical
  15318.      order. Adding `0' to the result causes MySQL to treat the result
  15319.      as a number.
  15320.  
  15321. column `id'
  15322.      This identifies a pair of twins. It is a key in all tables.
  15323.  
  15324. column `tvab'
  15325.      This identifies a twin in a pair. It has a value of `1' or `2'.
  15326.  
  15327. column `ptvab'
  15328.      This is an inverse of `tvab'. When `tvab' is `1' this is `2', and
  15329.      vice versa. It exists to save typing and to make it easier for
  15330.      MySQL to optimize the query.
  15331.  
  15332. This query demonstrates, among other things, how to do lookups on a
  15333. table from the same table with a join (`p1' and `p2'). In the example,
  15334. this is used to check whether a twin's partner died before the age of
  15335. 65. If so, the row is not returned.
  15336.  
  15337. All of the above exist in all tables with twin-related information. We
  15338. have a key on both `id,tvab' (all tables), and `id,ptvab'
  15339. (`person_data') to make queries faster.
  15340.  
  15341. On our production machine (A 200MHz UltraSPARC), this query returns
  15342. about 150-200 rows and takes less than one second.
  15343.  
  15344. The current number of records in the tables used in the query:
  15345. *Table*            *Rows*
  15346. `person_data'      71074
  15347. `lentus'           5291
  15348. `twin_project'     5286
  15349. `twin_data'        2012
  15350. `informant_data'   663
  15351. `harmony'          381
  15352. `postal_groups'    100
  15353.  
  15354. Show a Table of Twin Pair Status
  15355. --------------------------------
  15356.  
  15357. Each interview ends with a status code called `event'. The query shown
  15358. here is used to display a table over all twin pairs combined by event.
  15359. This indicates in how many pairs both twins are finished, in how many
  15360. pairs one twin is finished and the other refused, and so on.
  15361.  
  15362.      SELECT
  15363.              t1.event,
  15364.              t2.event,
  15365.              COUNT(*)
  15366.      FROM
  15367.              lentus AS t1,
  15368.              lentus AS t2,
  15369.              twin_project AS tp
  15370.      WHERE
  15371.              /* We are looking at one pair at a time */
  15372.              t1.id = tp.id
  15373.              AND t1.tvab=tp.tvab
  15374.              AND t1.id = t2.id
  15375.              /* Just the sceening survey */
  15376.              AND tp.survey_no = 5
  15377.              /* This makes each pair only appear once */
  15378.              AND t1.tvab='1' AND t2.tvab='2'
  15379.      GROUP BY
  15380.              t1.event, t2.event;
  15381.  
  15382. Using MySQL with Apache
  15383. =======================
  15384.  
  15385. There are programs that let you authenticate your users from a MySQL
  15386. database and also let you write your log files into a MySQL table.
  15387.  
  15388. You can change the Apache logging format to be easily readable by MySQL
  15389. by putting the following into the Apache configuration file:
  15390.  
  15391.      LogFormat \
  15392.              "\"%h\",%{%Y%m%d%H%M%S}t,%>s,\"%b\",\"%{Content-Type}o\",  \
  15393.              \"%U\",\"%{Referer}i\",\"%{User-Agent}i\""
  15394.  
  15395. To load a log file in that format into MySQL, you can use a statement
  15396. something like this:
  15397.  
  15398.      LOAD DATA INFILE '/LOCAL/ACCESS_LOG' INTO TABLE TBL_NAME
  15399.      FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\'
  15400.  
  15401. The named table should be created to have columns that correspond to
  15402. those that the `LogFormat' line writes to the log file.
  15403.  
  15404. Using MySQL Programs
  15405. ********************
  15406.  
  15407. This chapter provides a brief overview of the programs provided by
  15408. MySQL AB and discusses how to specify options when you run these
  15409. programs.  Most programs have options that are specific to their own
  15410. operation, but the syntax for specifying options is similar for all of
  15411. them. Later chapters provide more detailed descriptions of individual
  15412. programs, including which options they recognize.
  15413.  
  15414. Overview of MySQL Programs
  15415. ==========================
  15416.  
  15417. MySQL AB provides several types of programs:
  15418.  
  15419. The MYSQL server and server startup scripts:
  15420.         * `mysqld' is the MySQL server
  15421.  
  15422.         * `mysqld_safe', `mysql.server', and `mysqld_multi' are server
  15423.           startup scripts
  15424.  
  15425.         * `mysql_install_db' initializes the data directory and the
  15426.           initial databases
  15427.  
  15428.      These programs are discussed further in *Note MySQL Database
  15429.      Administration::.
  15430.  
  15431. Client programs that access the server:
  15432.         * `mysql' is a command-line client for executing SQL statements
  15433.           interactively or in batch mode
  15434.  
  15435.         * `mysqlcc' (MySQL Control Center) is an interactive graphical
  15436.           tool for executing SQL statements and administration
  15437.  
  15438.         * `mysqladmin' is an administrative client
  15439.  
  15440.         * `mysqlcheck' performs table maintenance operations
  15441.  
  15442.         * `mysqldump' and `mysqlhotcopy' make database backups
  15443.  
  15444.         * `mysqlimport' imports data files
  15445.  
  15446.         * `mysqlshow' displays information about databases and tables
  15447.  
  15448.      These programs are discussed further in *Note Client-Side
  15449.      Scripts::.
  15450.  
  15451. Utility programs that operate independently of the server:
  15452.         * `myisamchk' performs table maintenance operations
  15453.  
  15454.         * `myisampack' produces compressed, read-only tables
  15455.  
  15456.         * `mysqlbinlog' is a tool for processing binary log files
  15457.  
  15458.         * `perror' displays error code meanings
  15459.  
  15460.      `myisamchk' is discussed further in *Note MySQL Database
  15461.      Administration::.  The other programs are further in *Note
  15462.      Client-Side Scripts::.
  15463.  
  15464. Most MySQL distributions include all of these programs, except for those
  15465. programs that are platform-specific. (For example, the server startup
  15466. scripts are not used on Windows.) The exception is that RPM
  15467. distributions are more specialized. There is one RPM for the server,
  15468. another for the client programs, and so forth. If you appear to be
  15469. missing one or more programs, see *Note Installing:: for information on
  15470. types of distributions and what they contain.  It may be that you need
  15471. to install something else.
  15472.  
  15473. Invoking MySQL Programs
  15474. =======================
  15475.  
  15476. To invoke a MySQL program at the command line (that is, from your shell
  15477. or command prompt), enter the program name followed by any options or
  15478. other arguments needed to instruct the program what you want it to do.
  15479. The following commands show some sample program invocations. "`shell>'"
  15480. represents the prompt for your command interpreter; it is not part of
  15481. what you type.  The particular prompt you will see depends on your
  15482. command interpreter.  Typical prompts are `$' for `sh' or `bash', `%'
  15483. for `csh' or `tcsh', and `C:\>' for Windows `command.com' or `cmd.exe'.
  15484.  
  15485.      shell> mysql test
  15486.      shell> mysqladmin extended-status variables
  15487.      shell> mysqlshow --help
  15488.      shell> mysqldump --user=root personnel
  15489.  
  15490. Arguments that begin with a dash are option arguments. They typically
  15491. specify the type of connection a program should make to the server or
  15492. affect its operational mode. Options have a syntax that is described in
  15493. *Note Program Options::.
  15494.  
  15495. Non-option arguments (arguments with no leading dash) provide additional
  15496. information to the program. For example, the `mysql' program interprets
  15497. the first non-option argument as a database name, so the command `mysql
  15498. test' indicates that you want to use the `test' database.
  15499.  
  15500. Later sections that describe individual programs indicate which options
  15501. a program understands and describe the meaning of any additional
  15502. non-option arguments.
  15503.  
  15504. Some options are common to a number of programs. The most common of
  15505. these are the `--host', `--user', and `--password' options that specify
  15506. connection parameters. They indicate the host where the MySQL server is
  15507. running, and the username and password of your MySQL account. All MySQL
  15508. client programs understand these options; they allow you to specify
  15509. which server to connect to and the account to use on that server.
  15510.  
  15511. You may find it necessary to invoke MySQL programs using the pathname
  15512. to the `bin' directory in which they are installed. This is likely to
  15513. be the case if you get a "program not found" error whenever you attempt
  15514. to run a MySQL program from any directory other than the `bin'
  15515. directory.  To make it more convenient to use MySQL, you can add the
  15516. pathname of the `bin' directory to your `PATH' environment variable
  15517. setting. Then to run a program you need only type its name, not its
  15518. entire pathname.
  15519.  
  15520. Consult the documentation for your command interpreter for instructions
  15521. on setting your `PATH'. The syntax for setting environment variables is
  15522. interpreter-specific.
  15523.  
  15524. Specifying Program Options
  15525. ==========================
  15526.  
  15527. You can provide options for MySQL programs in several ways:
  15528.  
  15529.    * On the command line following the program name. This is most
  15530.      common for options that apply to a specific invocation of the
  15531.      program.
  15532.  
  15533.    * In an option file that the program reads when it starts. This is
  15534.      common for options that you want the program to use each time it
  15535.      runs.
  15536.  
  15537.    * In environment variables. These are useful for options that you
  15538.      want to apply each time the program runs, although in practice
  15539.      option files are used more commonly for this purpose.  (*Note
  15540.      Multiple Unix servers:: discusses one situation in which
  15541.      environment variables can be very helpful. It describes a handy
  15542.      technique that uses such variables to specify the TCP/IP port
  15543.      number and Unix socket file for both the server and client
  15544.      programs.)
  15545.  
  15546.  
  15547. MySQL programs determine which options are given first by examining
  15548. environment variables, then option files, and then the command line.
  15549. If an option is specified multiple times, the last occurrence takes
  15550. precedence.  This means that environment variables have the lowest
  15551. precedence and command-line options the highest.
  15552.  
  15553. You can take advantage of the way that MySQL programs process options by
  15554. specifying the default values for a program's options in an option
  15555. file. Then you need not type them each time you run the program, but
  15556. can override the defaults if necessary by using command-line options.
  15557.  
  15558. Using Options on the Command Line
  15559. ---------------------------------
  15560.  
  15561. Program options specified on the command line follow these rules:
  15562.  
  15563.    * Options are given after the command name.
  15564.  
  15565.    * An option argument begins with one dash or two dashes, depending
  15566.      on whether it has a short name or a long name. Many options have
  15567.      both forms.  For example, `-?' and `--help' are the short and long
  15568.      forms of the option that instructs a MySQL program to display a
  15569.      help message.
  15570.  
  15571.    * Option names are case sensitive.  `-v' and `-V' are both legal and
  15572.      have different meanings. (They are the corresponding short forms
  15573.      of the `--verbose' and `--version' options.)
  15574.  
  15575.    * Some options take a value following the option name.  For example,
  15576.      `-h localhost' or `--host=localhost' indicate the MySQL server
  15577.      host to a client program.  The option value tells the program the
  15578.      name of the host where the MySQL server is running.
  15579.  
  15580.    * For a long option that takes a value, separate the option name and
  15581.      the value by an `=' sign.  For a short option that takes a value,
  15582.      the option value can immediately follow the option letter, or
  15583.      there can be a space between.  (`-hlocalhost' and `-h localhost'
  15584.      are equivalent.)  An exception to this rule is the option for
  15585.      specifying your MySQL password.  This option can be given in long
  15586.      form as `--password=pass_val' or as `--password'. In the latter
  15587.      case (with no password value given), the program will prompt you
  15588.      for the password.  The password option also may be given in short
  15589.      form as `-ppass_val' or as `-p'. However, for the short form, if
  15590.      the password value is given, it must follow the option letter with
  15591.      _no intervening space_. The reason for this is that if a space
  15592.      follows the option letter, the program has no way to tell whether
  15593.      a following argument is supposed to be the password value or some
  15594.      other kind of argument.  Consequently, the following two commands
  15595.      have two completely different meanings:
  15596.  
  15597.           shell> mysql -ptest
  15598.           shell> mysql -p test
  15599.  
  15600.      The first command instructs `mysql' to use a password value of
  15601.      `test', but specifies no default database.  The second instructs
  15602.      `mysql' to prompt for the password value and to use `test' as the
  15603.      default database.
  15604.  
  15605.  
  15606. MySQL 4.0 introduced some additional flexibility in the way you specify
  15607. options. These changes were made in MySQL 4.0.2. Some of them relate to
  15608. the way you specify options that have "enabled" and "disabled" states,
  15609. and to the use of options that might be present in one version of MySQL
  15610. but not another.  Those capabilities are discussed in this section.
  15611. Another change pertains to the way you use options to set program
  15612. variables.  *Note Program variables:: discusses that topic further.
  15613.  
  15614. Some options control behavior that can be turned on or off. For example,
  15615. the `mysql' client supports a `--column-names' option that determines
  15616. whether or not to display a row of column names at the beginning of
  15617. query results. By default, this option is enabled. However, you may
  15618. want to disable it in some instances, such as when sending the output
  15619. of `mysql' into another program that expects to see only data and not
  15620. an initial header line.
  15621.  
  15622. To disable column names, you can specify the option using any of these
  15623. forms:
  15624.  
  15625.      --disable-column-names
  15626.      --skip-column-names
  15627.      --column-names=0
  15628.  
  15629. The `--disable' and `--skip' prefixes and the `=0' suffix all have the
  15630. same effect: They turn the option off.
  15631.  
  15632. The "enabled" form of the option may be specified in any of these ways:
  15633.  
  15634.      --column-names
  15635.      --enable-column-names
  15636.      --column-names=1
  15637.  
  15638. Another change to option processing introduced in MySQL 4.0 is that you
  15639. can use the `--loose' prefix for command-line options. If an option is
  15640. prefixed by `--loose', the program will not exit with an error if it
  15641. does not recognize the option, but instead will issue only a warning:
  15642.  
  15643.      shell> mysql --loose-no-such-option
  15644.      mysql: WARNING: unknown option '--no-such-option'
  15645.  
  15646. The `--loose' prefix can be useful when you run programs from multiple
  15647. installations of MySQL on the same machine, at least if all the
  15648. versions are as recent as 4.0.2.  This prefix is particularly useful
  15649. when you list options in an option file.  An option that may not be
  15650. recognized by all versions of a program can be given using the `--loose'
  15651. prefix (or `loose' in an option file). Versions of the program that do
  15652. not recognize the option will issue a warning and ignore it. This
  15653. strategy requires that versions involved be 4.0.2 or later, because
  15654. earlier versions know nothing of the `--loose' convention.
  15655.  
  15656. Using Option Files
  15657. ------------------
  15658.  
  15659. MySQL programs can read startup options from option files (also
  15660. sometimes called configuration files).  Option files provide a
  15661. convenient way to specify commonly used options so that they need not
  15662. be entered on the command line each time you run a program.  Option
  15663. file capability is available from MySQL 3.22 on.
  15664.  
  15665. The following programs support option files: `myisamchk', `myisampack',
  15666. `mysql', `mysql.server', `mysqladmin', `mysqlbinlog', `mysqlcc',
  15667. `mysqlcheck', `mysqld_safe', `mysqldump', `mysqld', `mysqlhotcopy',
  15668. `mysqlimport', and `mysqlshow'.
  15669.  
  15670. On Windows, MySQL programs read startup options from the following
  15671. files:
  15672.  
  15673. *Filename*             *Purpose*
  15674. `WINDIR\my.ini'        Global options
  15675. `C:\my.cnf'            Global options
  15676.  
  15677. WINDIR represents the location of your Windows directory.  This is
  15678. commonly `C:\Windows' or `C:\WinNT'.  You can determine its exact
  15679. location from the value of the `WINDIR' environment variable using the
  15680. following command:
  15681.  
  15682.      C:\> echo %WINDIR%
  15683.  
  15684. On Unix, MySQL programs read startup options from the following files:
  15685.  
  15686. *Filename*             *Purpose*
  15687. `/etc/my.cnf'          Global options
  15688. `DATADIR/my.cnf'       Server-specific options
  15689. `defaults-extra-file'  The file specified with
  15690.                        `--defaults-extra-file=PATH', if any
  15691. `~/.my.cnf'            User-specific options
  15692.  
  15693. DATADIR represents the location of the MySQL data directory. Typically
  15694. this is `/usr/local/mysql/data' for a binary installation or
  15695. `/usr/local/var' for a source installation.  Note that this is the data
  15696. directory location that was specified at configuration time, not the
  15697. one specified with `--datadir' when `mysqld' starts.  Use of
  15698. `--datadir' at runtime has no effect on where the server looks for
  15699. option files, because it looks for them before processing any
  15700. command-line arguments.
  15701.  
  15702. MySQL looks for option files in the order just described and reads any
  15703. that exist. If an option file that you want to use does not exist,
  15704. create it with a plain text editor.  If multiple option files exist, an
  15705. option specified in a file read later takes precedence over the same
  15706. option specified in a file read earlier.
  15707.  
  15708. Any long option that may be given on the command line when running a
  15709. MySQL program can be given in an option file as well.  To get the list
  15710. of available options for a program, run it with the `--help' option.
  15711.  
  15712. The syntax for specifying options in an option file is similar to
  15713. command-line syntax, except that you omit the leading two dashes. For
  15714. example, `--quick' or `--host=localhost' on the command line should be
  15715. specified as `quick' or `host=localhost' in an option file.  To specify
  15716. an option of the form `--loose-opt_name' in an option file, write it as
  15717. `loose-opt_name'.
  15718.  
  15719. Empty lines in option files are ignored. Non-empty lines can take any
  15720. of the following forms:
  15721.  
  15722. `#COMMENT'
  15723. `;COMMENT'
  15724.      Comment lines start with `#' or `;'. As of MySQL 4.0.14, a
  15725.      `#'-comment can start in the middle of a line as well.
  15726.  
  15727. `[GROUP]'
  15728.      GROUP is the name of the program or group for which you want to set
  15729.      options.  After a group line, any OPT_NAME or `set-variable' lines
  15730.      apply to the named group until the end of the option file or
  15731.      another group line is given.
  15732.  
  15733. `OPT_NAME'
  15734.      This is equivalent to `--OPT_NAME' on the command line.
  15735.  
  15736. `OPT_NAME=VALUE'
  15737.      This is equivalent to `--OPT_NAME=VALUE' on the command line.  In
  15738.      an option file, you can have spaces around the `=' character,
  15739.      something that is not true on the command line.  As of MySQL
  15740.      4.0.16, you can quote the value with double quotes or single
  15741.      quotes.  This is useful if the value contains a `#' comment
  15742.      character or whitespace.
  15743.  
  15744. `set-variable = VAR_NAME=VALUE'
  15745.      Set the program variable VAR_NAME to the given value.  This is
  15746.      equivalent to `--set-variable=VAR_NAME=VALUE' on the command line.
  15747.      Spaces are allowed around the first `=' character but not around
  15748.      the second.  This syntax is deprecated as of MySQL 4.0.  See *Note
  15749.      Program variables:: for more information on setting program
  15750.      variables.
  15751.  
  15752. Leading and trailing blanks are automatically deleted from option names
  15753. and values.  You may use the escape sequences `\b', `\t', `\n', `\r',
  15754. `\\', and `\s' in option values to represent the backspace, tab,
  15755. newline, carriage return, and space characters.
  15756.  
  15757. On Windows, if an option value represents a pathname, you should
  15758. specify the value using `/' rather than `\' as the pathname separator.
  15759. If you use `\', you must double it as `\\', because `\' is the escape
  15760. character in MySQL.
  15761.  
  15762. If an option group name is the same as a program name, options in the
  15763. group apply specifically to that program.
  15764.  
  15765. The `[client]' option group is read by all client programs (but not by
  15766. `mysqld'). This allows you to specify options that apply to every
  15767. client. For example, `[client]' is the perfect group to use to specify
  15768. the password that you use to connect to the server.  (But make sure that
  15769. the option file is readable and writable only by yourself, so that other
  15770. people cannot find out your password.) Be sure not to put an option in
  15771. the `[client]' group unless it is recognized by _all_ client programs
  15772. that you use. Programs that do not understand the option will quit after
  15773. displaying an error message if you try to run them.
  15774.  
  15775. As of MySQL 4.0.14, if you want to create option groups that should be
  15776. read only by one specific `mysqld' server release series, you can do
  15777. this by using groups with names of `[mysqld-4.0]', `[mysqld-4.1]', and
  15778. so forth. The following group indicates that the `--new' option should
  15779. be used only by MySQL servers with 4.0.x version numbers:
  15780.  
  15781.      [mysqld-4.0]
  15782.      new
  15783.  
  15784. Here is a typical global option file:
  15785.  
  15786.      [client]
  15787.      port=3306
  15788.      socket=/tmp/mysql.sock
  15789.      
  15790.      [mysqld]
  15791.      port=3306
  15792.      socket=/tmp/mysql.sock
  15793.      key_buffer_size=16M
  15794.      max_allowed_packet=8M
  15795.      
  15796.      [mysqldump]
  15797.      quick
  15798.  
  15799. The preceding option file uses `VAR_NAME=VALUE' syntax for the lines
  15800. that set the `key_buffer_size' and `max_allowed_packet' variables.
  15801. Prior to MySQL 4.0.2, you would need to use `set-variable' syntax
  15802. instead (described earlier in this section).
  15803.  
  15804. Here is a typical user option file:
  15805.  
  15806.      [client]
  15807.      # The following password will be sent to all standard MySQL clients
  15808.      password="my_password"
  15809.      
  15810.      [mysql]
  15811.      no-auto-rehash
  15812.      set-variable = connect_timeout=2
  15813.      
  15814.      [mysqlhotcopy]
  15815.      interactive-timeout
  15816.  
  15817. This option file uses `set-variable' syntax to set the
  15818. `connect_timeout' variable. For MySQL 4.0.2 and up, you can also set
  15819. the variable using just `connect_timeout=2'.
  15820.  
  15821. If you have a source distribution, you will find sample option files
  15822. named `my-XXXX.cnf' in the `support-files' directory.  If you have a
  15823. binary distribution, look in the `support-files' directory under your
  15824. MySQL installation directory (typically `C:\mysql' on Windows or
  15825. `/usr/local/mysql' on Unix).  Currently there are sample option files
  15826. for small, medium, large, and very large systems. To experiment with
  15827. one of these files, copy it to `C:\my.cnf' on Windows or to `.my.cnf'
  15828. in your home directory on Unix.
  15829.  
  15830. *Note*: On Windows, the `.cnf' option file extension might not be
  15831. displayed.
  15832.  
  15833. All MySQL programs that support option files handle the following
  15834. command-line options:
  15835.  
  15836. `--no-defaults'
  15837.      Don't read any option files.
  15838.  
  15839. `--print-defaults'
  15840.      Print the program name and all options that it will get from
  15841.      option files.
  15842.  
  15843. `--defaults-file=PATH_NAME'
  15844.      Use only the given option file. PATH_NAME is the full pathname to
  15845.      the file.
  15846.  
  15847. `--defaults-extra-file=PATH_NAME'
  15848.      Read this option file after the global option file but before the
  15849.      user option file. PATH_NAME is the full pathname to the file.
  15850.  
  15851. To work properly, each of these options must immediately follow the
  15852. command name on the command line, with the exception that
  15853. `--print-defaults' may be used immediately after `--defaults-file' or
  15854. `--defaults-extra-file'.
  15855.  
  15856. In shell scripts, you can use the `my_print_defaults' program to parse
  15857. option files. The following example shows the output that
  15858. `my_print_defaults' might produce when asked to show the options found
  15859. in the `[client]' and `[mysql]' groups:
  15860.  
  15861.      shell> my_print_defaults client mysql
  15862.      --port=3306
  15863.      --socket=/tmp/mysql.sock
  15864.      --no-auto-rehash
  15865.  
  15866. Note for developers:  Option file handling is implemented in the C
  15867. client library simply by processing all matching options (that is,
  15868. options in the appropriate group) before any command-line arguments.
  15869. This works nicely for programs that use the last instance of an option
  15870. that is specified multiple times. If you have a C or C++ program that
  15871. handles multiply specified options this way but doesn't read option
  15872. files, you need add only two lines to give it that capability.  Check
  15873. the source code of any of the standard MySQL clients to see how to do
  15874. this.
  15875.  
  15876. Several other language interfaces to MySQL are based on the C client
  15877. library, and some of them provide a way to access option file contents.
  15878. These include Perl and Python. See the documentation for your preferred
  15879. interface for details.
  15880.  
  15881. Using Environment Variables to Specify Options
  15882. ----------------------------------------------
  15883.  
  15884. To specify an option using an environment variable, set the variable
  15885. using the syntax appropriate for your comment processor. For example,
  15886. on Windows or NetWare, you can set the `USER' variable to specify your
  15887. MySQL account name.  To do so, use this syntax:
  15888.  
  15889.      SET USER=YOUR_NAME
  15890.  
  15891. The syntax on Unix depends on your shell. Suppose that you want to
  15892. specify the TCP/IP port number using the `MYSQL_TCP_PORT' variable. The
  15893. syntax for Bourne shell and variants (`sh', `bash', `zsh', etc.) is:
  15894.  
  15895.      MYSQL_TCP_PORT=3306
  15896.  
  15897. For `csh' and `tcsh', use this syntax:
  15898.  
  15899.      setenv MYSQL_TCP_PORT 3306
  15900.  
  15901. The commands to set environment variables can be executed at your
  15902. command prompt to take effect immediately. These settings persist until
  15903. you log out.  To have the settings take effect each time you log in,
  15904. place the appropriate command or commands in a startup file that your
  15905. command interpreter reads each time it starts. Typical startup files are
  15906. `AUTOEXEC.BAT' for Windows, `.bash_profile' for `bash', or `.tcshrc'
  15907. for `tcsh'. Consult the documentation for your command interpreter for
  15908. specific details.
  15909.  
  15910. *Note Environment variables:: lists all environment variables that
  15911. affect MySQL program operation.
  15912.  
  15913. Using Options to Set Program Variables
  15914. --------------------------------------
  15915.  
  15916. Many MySQL programs have internal variables that can be set at runtime.
  15917. As of MySQL 4.0.2, program variables are set the same way as any other
  15918. long option that takes a value.  For example, `mysql' has a
  15919. `max_allowed_packet' variable that controls the maximum size of its
  15920. communication buffer.  To set the `max_allowed_packet' variable for
  15921. `mysql' to a value of 16MB, use either of the following commands:
  15922.  
  15923.      shell> mysql --max_allowed_packet=16777216
  15924.      shell> mysql --max_allowed_packet=16M
  15925.  
  15926. The first command specifies the value in bytes. The second specifies
  15927. the value in megabytes. Variable values can have a suffix of `K', `M',
  15928. or `G' (either uppercase or lowercase) to indicate units of kilobytes,
  15929. megabytes, or gigabytes.
  15930.  
  15931. In an option file, the variable setting is given without the leading
  15932. dashes:
  15933.  
  15934.      [mysql]
  15935.      max_allowed_packet=16777216
  15936.  
  15937. Or:
  15938.  
  15939.      [mysql]
  15940.      max_allowed_packet=16M
  15941.  
  15942. If you like, underscores in a variable name can be specified as dashes.
  15943.  
  15944. Prior to MySQL 4.0.2, program variable names are not recognized as
  15945. option names.  Instead, use the `--set-variable' option to assign a
  15946. value to a variable:
  15947.  
  15948.      shell> mysql --set-variable=max_allowed_packet=16777216
  15949.      shell> mysql --set-variable=max_allowed_packet=16M
  15950.  
  15951. In an option file, omit the leading dashes:
  15952.  
  15953.      [mysql]
  15954.      set-variable = max_allowed_packet=16777216
  15955.  
  15956. Or:
  15957.  
  15958.      [mysql]
  15959.      set-variable = max_allowed_packet=16M
  15960.  
  15961. With `--set-variable', underscores in variable names cannot be given as
  15962. dashes for versions of MySQL older than 4.0.2.
  15963.  
  15964. The `--set-variable' option is still recognized in MySQL 4.0.2 and up,
  15965. but is deprecated.
  15966.  
  15967. Some server variables can be set at runtime. For details, see *Note
  15968. Dynamic System Variables::.
  15969.  
  15970. Database Administration
  15971. ***********************
  15972.  
  15973. This chapter covers topics that deal with administering a MySQL
  15974. installation, such as configuring the server, managing user accounts,
  15975. and performing backups.
  15976.  
  15977. The MySQL Server and Server Startup Scripts
  15978. ===========================================
  15979.  
  15980. The MySQL server, `mysqld', is the main program that does most of the
  15981. work in a MySQL installation. The server is accompanied by several
  15982. related scripts that perform setup operations when you install MySQL or
  15983. that are helper programs to assist you in starting and stopping the
  15984. server.
  15985.  
  15986. This section provides an overview of the server and related programs,
  15987. and information about server startup scripts. Information about
  15988. configuring the server itself is given in *Note Configuring MySQL::.
  15989.  
  15990. Overview of the Server-Side Scripts and Utilities
  15991. -------------------------------------------------
  15992.  
  15993. All MySQL programs take many different options. However, every MySQL
  15994. program provides a `--help' option that you can use to get a
  15995. description of the program's options. For example, try `mysqld --help'.
  15996.  
  15997. You can override default options for all standard programs by specifying
  15998. options on the command line or in an option file.  *Note Program
  15999. Options::.
  16000.  
  16001. The following list briefly describes the MySQL server and server-related
  16002. programs:
  16003.  
  16004. `mysqld'
  16005.      The SQL daemon (that is, the MySQL server). To use client
  16006.      programs, this program must be running, because clients gain
  16007.      access to databases by connecting to the server.  *Note
  16008.      Configuring MySQL::.
  16009.  
  16010. `mysqld-max'
  16011.      A version of the server that includes additional features.  *Note
  16012.      `mysqld-max': mysqld-max.
  16013.  
  16014. `mysqld_safe'
  16015.      A server startup script.  `mysqld_safe' attempts to start
  16016.      `mysqld-max' if it exists, and `mysqld' otherwise.  *Note
  16017.      `mysqld_safe': mysqld_safe.
  16018.  
  16019. `mysql.server'
  16020.      A server startup script.  This script is used on systems that use
  16021.      run directories containing scripts that start system services for
  16022.      particular run levels. It invokes `mysqld_safe' to start the MySQL
  16023.      server.  *Note `mysql.server': mysql.server.
  16024.  
  16025. `mysqld_multi'
  16026.      A server startup script that can start or stop multiple servers
  16027.      installed on the system.  *Note `mysqld_multi': mysqld_multi.
  16028.  
  16029. `mysql_install_db'
  16030.      This script creates the MySQL grant tables with default
  16031.      privileges. It is usually executed only once, when first
  16032.      installing MySQL on a system.
  16033.  
  16034. `mysql_fix_privilege_tables'
  16035.      This script is used after an upgrade install operation, to update
  16036.      the grant tables with any changes that have been made in newer
  16037.      versions of MySQL.
  16038.  
  16039. There are several other programs that also are run on the server host:
  16040.  
  16041. `myisamchk'
  16042.      A utility to describe, check, optimize, and repair `MyISAM' tables.
  16043.      `myisamchk' is described in *Note Table maintenance::.
  16044.  
  16045. `make_binary_distribution'
  16046.      This program makes a binary release of a compiled MySQL. This
  16047.      could be sent by FTP to `/pub/mysql/upload/' on `ftp.mysql.com'
  16048.      for the convenience of other MySQL users.
  16049.  
  16050. `mysqlbug'
  16051.      The MySQL bug reporting script.  It can be used to send a bug
  16052.      report to the MySQL mailing list. (You can also visit
  16053.      `http://bugs.mysql.com/' to file a bug report online.)
  16054.  
  16055. The `mysqld-max' Extended MySQL Server
  16056. --------------------------------------
  16057.  
  16058. A MySQL-Max server is a version of the `mysqld' MySQL server that has
  16059. been built to include additional features.
  16060.  
  16061. The distribution to use depends on your platform:
  16062.  
  16063.    * For Windows, MySQL binary distributions include both the standard
  16064.      server (`mysqld.exe') and the MySQL-Max server (`mysqld-max.exe'),
  16065.      so you need not get a special distribution. Just use a regular
  16066.      Windows distribution, available at
  16067.      `http://dev.mysql.com/downloads/mysql-4.0.html'.  *Note Windows
  16068.      installation::.
  16069.  
  16070.    * For Linux, if you install MySQL using RPM distributions, use the
  16071.      regular `MySQL-server' RPM first to install a standard server named
  16072.      `mysqld'.  Then use the `MySQL-Max' RPM to install a server named
  16073.      `mysqld-max'.  The `MySQL-Max' RPM presupposes that you have
  16074.      already installed the regular server RPM.  See *Note Linux-RPM::
  16075.      for more information on the Linux RPM packages.
  16076.  
  16077.    * All other MySQL-Max distributions contain a single server that is
  16078.      named `mysqld' but that has the additional features included.
  16079.  
  16080.  
  16081. You can find the MySQL-Max binaries on the MySQL AB Web site at
  16082. `http://dev.mysql.com/downloads/mysql-4.0.html'.
  16083.  
  16084. MySQL AB builds the MySQL-Max servers by using the following
  16085. `configure' options:
  16086.  
  16087. `--with-server-suffix=-max'
  16088.      This option adds a `-max' suffix to the `mysqld' version string.
  16089.  
  16090. `--with-innodb'
  16091.      This option enables support for the `InnoDB' storage engine.
  16092.      MySQL-Max servers always include `InnoDB' support, but this option
  16093.      actually is needed only for MySQL 3.23.  From MySQL 4 on, `InnoDB'
  16094.      is included by default in binary distributions, so you do not need
  16095.      a MySQL-Max server to obtain `InnoDB' support.
  16096.  
  16097. `--with-bdb'
  16098.      This option enables support for the Berkeley DB (`BDB') storage
  16099.      engine.
  16100.  
  16101. `CFLAGS=-DUSE_SYMDIR'
  16102.      This define enables symbolic link support for Windows.
  16103.  
  16104. MySQL-Max binary distributions are a convenience for those who wish to
  16105. install precompiled programs. If you build MySQL using a source
  16106. distribution, you can build your own Max-like server by enabling the
  16107. same features at configuration time that the MySQL-Max binary
  16108. distributions are built with.
  16109.  
  16110. MySQL-Max servers include the BerkeleyDB (`BDB') storage engine
  16111. whenever possible, but not all platforms support `BDB'.  The following
  16112. table shows which platforms allow MySQL-Max binaries to include `BDB':
  16113.  
  16114. *System*       `BDB'
  16115.                *Support*
  16116. AIX 4.3        N
  16117. HP-UX 11.0     N
  16118. Linux-Alpha    N
  16119. Linux-IA-64    N
  16120. Linux-Intel    Y
  16121. Mac OS X       N
  16122. NetWare        N
  16123. SCO OSR5       Y
  16124. Solaris-Intel  N
  16125. Solaris-SPARC  Y
  16126. UnixWare       Y
  16127. Windows/NT     Y
  16128.  
  16129. To find out which storage engines your server supports, issue the
  16130. following statement:
  16131.  
  16132.      mysql> SHOW ENGINES;
  16133.  
  16134. Before MySQL 4.1.2, `SHOW ENGINES' is unavailable. Use the following
  16135. statement instead and check the value of the variable for the storage
  16136. engine in which you are interested:
  16137.  
  16138.      mysql> SHOW VARIABLES LIKE 'have_%';
  16139.      +------------------+----------+
  16140.      | Variable_name    | Value    |
  16141.      +------------------+----------+
  16142.      | have_bdb         | NO       |
  16143.      | have_crypt       | YES      |
  16144.      | have_innodb      | YES      |
  16145.      | have_isam        | NO       |
  16146.      | have_raid        | NO       |
  16147.      | have_symlink     | DISABLED |
  16148.      | have_openssl     | NO       |
  16149.      | have_query_cache | YES      |
  16150.      +------------------+----------+
  16151.  
  16152. The values in the second column indicate the server's level of support
  16153. for each feature:
  16154.  
  16155. *Value*     *Meaning*
  16156. `YES'       The feature is supported and is active.
  16157. `NO'        The feature is not supported.
  16158. `DISABLED'  The feature is supported but has been disabled.
  16159.  
  16160. A value of `NO' means that the server was compiled without support for
  16161. the feature, so it cannot be activated at runtime.
  16162.  
  16163. A value of `DISABLED' occurs either because the server was started with
  16164. an option that disables the feature, or because not all options
  16165. required to enable it were given. In the latter case, the
  16166. `HOST_NAME.err' error log file should contain a reason indicating why
  16167. the option is disabled.
  16168.  
  16169. One situation in which you might see `DISABLED' occurs with MySQL 3.23
  16170. when the `InnoDB' storage engine is compiled in. In MySQL 3.23, you
  16171. must supply at least the `innodb_data_file_path' option at runtime to
  16172. set up the `InnoDB' tablespace. Without this option, `InnoDB' disables
  16173. itself.  *Note `InnoDB' in MySQL 3.23: InnoDB in MySQL 3.23.  You can
  16174. specify configuration options for the `BDB' storage engine, too, but
  16175. `BDB' will not disable itself if you do not provide them.  *Note `BDB'
  16176. start: BDB start.
  16177.  
  16178. You might also see `DISABLED' for the `InnoDB', `BDB', or `ISAM'
  16179. storage engines if the server was compiled to support them, but was
  16180. started with the `--skip-innodb', `--skip-bdb', or `--skip-isam'
  16181. options at runtime.
  16182.  
  16183. As of Version 3.23, all MySQL servers support `MyISAM' tables, because
  16184. `MyISAM' is the default storage engine.
  16185.  
  16186. The `mysqld_safe' Server Startup Script
  16187. ---------------------------------------
  16188.  
  16189. `mysqld_safe' is the recommended way to start a `mysqld' server on Unix
  16190. and NetWare.  `mysqld_safe' adds some safety features such as
  16191. restarting the server when an error occurs and logging runtime
  16192. information to an error log file. NetWare-specific behaviors are listed
  16193. later in this section.
  16194.  
  16195. *Note*: Before MySQL 4.0, `mysqld_safe' is named `safe_mysqld'.  To
  16196. preserve backward compatibility, MySQL binary distributions for some
  16197. time will include `safe_mysqld' as a symbolic link to `mysqld_safe'.
  16198.  
  16199. By default, `mysqld_safe' tries to start an executable named
  16200. `mysqld-max' if it exists, or `mysqld' otherwise.  Be aware of the
  16201. implications of this behavior:
  16202.  
  16203.    * On Linux, the `MySQL-Max' RPM relies on this `mysqld_safe'
  16204.      behavior. The RPM installs an executable named `mysqld-max', which
  16205.      causes `mysqld_safe' to automatically use that executable from that
  16206.      point on.
  16207.  
  16208.    * If you install a MySQL-Max distribution that includes a server
  16209.      named `mysqld-max', then upgrade later to a non-Max version of
  16210.      MySQL, `mysqld_safe' will still attempt to run the old `mysqld-max'
  16211.      server.  If you perform such an upgrade, you should manually
  16212.      remove the old `mysqld-max' server to ensure that `mysqld_safe'
  16213.      runs the new `mysqld' server.
  16214.  
  16215.  
  16216. To override the default behavior and specify explicitly which server you
  16217. want to run, specify a `--mysqld' or `--mysqld-version' option to
  16218. `mysqld_safe'.
  16219.  
  16220. Many of the options to `mysqld_safe' are the same as the options to
  16221. `mysqld'. *Note Server options::.
  16222.  
  16223. All options specified to `mysqld_safe' on the command line are passed
  16224. to `mysqld'.  If you want to use any options that are specific to
  16225. `mysqld_safe' and that `mysqld' doesn't support, do not specify them on
  16226. the command line. Instead, list them in the `[mysqld_safe]' group of an
  16227. option file.  *Note Option files::.
  16228.  
  16229. `mysqld_safe' reads all options from the `[mysqld]', `[server]', and
  16230. `[mysqld_safe]' sections in option files.  For backward compatibility,
  16231. it also reads `[safe_mysqld]' sections, although you should rename such
  16232. sections to `[mysqld_safe]' when you begin using MySQL 4.0 or later.
  16233.  
  16234. `mysqld_safe' supports the following options:
  16235.  
  16236. `--basedir=PATH'
  16237.      The path to the MySQL installation directory.
  16238.  
  16239. `--core-file-size=SIZE'
  16240.      The size of the core file `mysqld' should be able to create. The
  16241.      option value is passed to `ulimit -c'.
  16242.  
  16243. `--datadir=PATH'
  16244.      The path to the data directory.
  16245.  
  16246. `--defaults-extra-file=PATH'
  16247.      The name of an option file to be read in addition to the usual
  16248.      option files.
  16249.  
  16250. `--defaults-file=PATH'
  16251.      The name of an option file to be read instead of the usual option
  16252.      files.
  16253.  
  16254. `--err-log=PATH'
  16255.      The old form of the `--log-error' option, to be used before MySQL
  16256.      4.0.
  16257.  
  16258. `--ledir=PATH'
  16259.      The path to the directory containing the `mysqld' program.  Use
  16260.      this option to explicitly indicate the location of the server.
  16261.  
  16262. `--log-error=PATH'
  16263.      Write the error log to the given file. *Note Error log::.
  16264.  
  16265. `--mysqld=PROG_NAME'
  16266.      The name of the server program (in the `ledir' directory) that you
  16267.      want to start. This option is needed if you use the MySQL binary
  16268.      distribution but have the data directory outside of the binary
  16269.      distribution.
  16270.  
  16271. `--mysqld-version=SUFFIX'
  16272.      This option is similar to the `--mysqld' option, but you specify
  16273.      only the suffix for the server program name. The basename is
  16274.      assumed to be `mysqld'.  For example, if you use
  16275.      `--mysqld-version=max', `mysqld_safe' will start the `mysqld-max'
  16276.      program in the `ledir' directory.  If the argument to
  16277.      `--mysqld-version' is empty, `mysqld_safe' uses `mysqld' in the
  16278.      `ledir' directory.
  16279.  
  16280. `--nice=PRIORITY'
  16281.      Use the `nice' program to set the server's scheduling priority to
  16282.      the given value.  This option was added in MySQL 4.0.14.
  16283.  
  16284. `--no-defaults'
  16285.      Do not read any option files.
  16286.  
  16287. `--open-files-limit=COUNT'
  16288.      The number of files `mysqld' should be able to open. The option
  16289.      value is passed to `ulimit -n'. Note that you need to start
  16290.      `mysqld_safe' as `root' for this to work properly!
  16291.  
  16292. `--pid-file=PATH'
  16293.      The path to the process ID file.
  16294.  
  16295. `--port=PORT_NUM'
  16296.      The port number to use when listening for TCP/IP connections.
  16297.  
  16298. `--socket=PATH'
  16299.      The Unix socket file to use for local connections.
  16300.  
  16301. `--timezone=ZONE'
  16302.      Set the `TZ' time zone environment variable to the given option
  16303.      value.  Consult your operating system documentation for legal time
  16304.      zone specification formats.
  16305.  
  16306. `--user={USER_NAME | USER_ID}'
  16307.      Run the `mysqld' server as the user having the name USER_NAME or
  16308.      the numeric user ID USER_ID.  ("User" in this context refers to a
  16309.      system login account, not a MySQL user listed in the grant tables.)
  16310.  
  16311. The `mysqld_safe' script is written so that it normally can start a
  16312. server that was installed from either a source or a binary distribution
  16313. of MySQL, even though these types of distributions typically install
  16314. the server in slightly different locations.  (*Note Installation
  16315. layouts::.)  `mysqld_safe' expects one of the following conditions to
  16316. be true:
  16317.  
  16318.    * The server and databases can be found relative to the directory
  16319.      from which `mysqld_safe' is invoked.  For binary distributions,
  16320.      `mysqld_safe' looks under its working directory for `bin' and
  16321.      `data' directories.  For source distributions, it looks for
  16322.      `libexec' and `var' directories.  This condition should be met if
  16323.      you execute `mysqld_safe' from your MySQL installation directory
  16324.      (for example, `/usr/local/mysql' for a binary distribution).
  16325.  
  16326.    * If the server and databases cannot be found relative to the working
  16327.      directory, `mysqld_safe' attempts to locate them by absolute
  16328.      pathnames.  Typical locations are `/usr/local/libexec' and
  16329.      `/usr/local/var'.  The actual locations are determined from the
  16330.      values configured into the distribution at the time it was built.
  16331.      They should be correct if MySQL is installed in the location
  16332.      specified at configuration time.
  16333.  
  16334. Because `mysqld_safe' will try to find the server and databases relative
  16335. to its own working directory, you can install a binary distribution of
  16336. MySQL anywhere, as long as you run `mysqld_safe' from the MySQL
  16337. installation directory:
  16338.  
  16339.      shell> cd mysql_installation_directory
  16340.      shell> bin/mysqld_safe &
  16341.  
  16342. If `mysqld_safe' fails, even when invoked from the MySQL installation
  16343. directory, you can specify the `--ledir' and `--datadir' options to
  16344. indicate the directories in which the server and databases are located
  16345. on your system.
  16346.  
  16347. Normally, you should not edit the `mysqld_safe' script.  Instead,
  16348. configure `mysqld_safe' by using command-line options or options in the
  16349. `[mysqld_safe]' section of a `my.cnf' option file.  In rare cases, it
  16350. might be necessary to edit `mysqld_safe' to get it to start the server
  16351. properly. However, if you do this, your modified version of
  16352. `mysqld_safe' might be overwritten if you upgrade MySQL in the future,
  16353. so you should make a copy of your edited version that you can reinstall.
  16354.  
  16355. On NetWare, `mysqld_safe' is a NetWare Loadable Module (NLM) that is
  16356. ported from the original Unix shell script.  It does the following:
  16357.  
  16358.   1. Runs a number of system and option checks.
  16359.  
  16360.   2. Runs a check on `MyISAM' and `ISAM' tables.
  16361.  
  16362.   3. Provides a screen presence for the MySQL server.
  16363.  
  16364.   4. Starts `mysqld', monitors it, and restarts it if it terminates in
  16365.      error.
  16366.  
  16367.   5. Sends error messages from `mysqld' to the `HOST_NAME.err' file in
  16368.      the data directory.
  16369.  
  16370.   6. Sends `mysqld_safe' screen output to the `HOST_NAME.safe' file in
  16371.      the data directory.
  16372.  
  16373.  
  16374. The `mysql.server' Server Startup Script
  16375. ----------------------------------------
  16376.  
  16377. MySQL distributions on Unix include a script named `mysql.server'.  It
  16378. can be used on systems such as Linux and Solaris that use System V-style
  16379. run directories to start and stop system services. It is also used by
  16380. the Mac OS X Startup Item for MySQL.
  16381.  
  16382. `mysql.server' can be found in the `support-files' directory under your
  16383. MySQL installation directory or in a MySQL source tree.
  16384.  
  16385. If you use the Linux server RPM package (`MySQL-server-VERSION.rpm'),
  16386. the `mysql.server' script will already have been installed in the
  16387. `/etc/init.d' directory with the name `mysql'. You need not install it
  16388. manually. See *Note Linux-RPM:: for more information on the Linux RPM
  16389. packages.
  16390.  
  16391. Some vendors provide RPM packages that install a startup script under a
  16392. different name such as `mysqld'.
  16393.  
  16394. If you install MySQL from a source distribution or using a binary
  16395. distribution format that does not install `mysql.server' automatically,
  16396. you can install it manually. Instructions are provided in *Note
  16397. Automatic start::.
  16398.  
  16399. `mysql.server' reads options from the `[mysql.server]' and `[mysqld]'
  16400. sections of option files.  (For backward compatibility, it also reads
  16401. `[mysql_server]' sections, although you should rename such sections to
  16402. `[mysql.server]' when you begin using MySQL 4.0 or later.)
  16403.  
  16404. The `mysqld_multi' Program for Managing Multiple MySQL Servers
  16405. --------------------------------------------------------------
  16406.  
  16407. `mysqld_multi' is meant for managing several `mysqld' processes that
  16408. listen for connections on different Unix socket files and TCP/IP ports.
  16409. It can start or stop servers, or report their current status.
  16410.  
  16411. The program searches for groups named `[mysqld#]' in `my.cnf' (or in
  16412. the file named by the `--config-file' option).  `#' can be any positive
  16413. integer.  This number is referred to in the following discussion as the
  16414. option group number, or GNR.  Group numbers distinguish option groups
  16415. from one another and are used as arguments to `mysqld_multi' to specify
  16416. which servers you want to start, stop, or obtain a status report for.
  16417. Options listed in these groups are the same that you would use in the
  16418. `[mysqld]' group used for starting `mysqld'.  (See, for example, *Note
  16419. Automatic start::.) However, when using multiple servers it is necessary
  16420. that each one use its own value for options such as the Unix socket
  16421. file and TCP/IP port number. For more information on which options must
  16422. be unique per server in a multiple-server environment, see *Note
  16423. Multiple servers::.
  16424.  
  16425. To invoke `mysqld_multi', use the following syntax:
  16426.  
  16427.      shell> mysqld_multi [OPTIONS] {start|stop|report} [GNR[,GNR]...]
  16428.  
  16429. `start', `stop', and `report' indicate which operation you want to
  16430. perform. You can perform the designated operation on a single server or
  16431. multiple servers, depending on the GNR list that follows the option
  16432. name.  If there is no list, `mysqld_multi' performs the operation for
  16433. all servers in the option file.
  16434.  
  16435. Each GNR value represents an option group number or range of group
  16436. numbers.  The value should be the number at the end of the group name
  16437. in the option file.  For example, the GNR for a group named `[mysqld17]'
  16438. is `17'.  To specify a range of numbers, separate the first and last
  16439. numbers by a dash.  The GNR value `10-13' represents groups
  16440. `[mysqld10]' through `[mysqld13]'.  Multiple groups or group ranges can
  16441. be specified on the command line, separated by commas.  There must be
  16442. no whitespace characters (spaces or tabs) in the GNR list; anything
  16443. after a whitespace character is ignored.
  16444.  
  16445. This command starts a single server using option group `[mysqld17]':
  16446.  
  16447.      shell> mysqld_multi start 17
  16448.  
  16449. This command stops several servers, using option groups `[mysql8]' and
  16450. `[mysqld10]' through `[mysqld13]':
  16451.  
  16452.      shell> mysqld_multi start 8,10-13
  16453.  
  16454. For an example of how you might set up an option file, use this command:
  16455.  
  16456.      shell> mysqld_multi --example
  16457.  
  16458. `mysqld_multi' supports the following options:
  16459.  
  16460. `--config-file=NAME'
  16461.      Specify the name of an alternative option file. This affects where
  16462.      `mysqld_multi' looks for `[mysqld#]' option groups.  Without this
  16463.      option, all options are read from the usual `my.cnf' file.  The
  16464.      option does not affect where `mysqld_multi' reads its own options,
  16465.      which are always taken from the `[mysqld_multi]' group in the
  16466.      usual `my.cnf' file.
  16467.  
  16468. `--example'
  16469.      Display a sample option file.
  16470.  
  16471. `--help'
  16472.      Display a help message and exit.
  16473.  
  16474. `--log=NAME'
  16475.      Specify the name of the log file. If the file exists, log output
  16476.      is appended to it.
  16477.  
  16478. `--mysqladmin=PROG_NAME'
  16479.      The `mysqladmin' binary to be used to stop servers.
  16480.  
  16481. `--mysqld=PROG_NAME'
  16482.      The `mysqld' binary to be used. Note that you can specify
  16483.      `mysqld_safe' as the value for this option also. The options are
  16484.      passed to `mysqld'. Just make sure that you have the directory
  16485.      where `mysqld' is located in your `PATH' environment variable
  16486.      setting or fix `mysqld_safe'.
  16487.  
  16488. `--no-log'
  16489.      Print log information to stdout rather than to the log file. By
  16490.      default, output goes to the log file.
  16491.  
  16492. `--password=PASSWORD'
  16493.      The password of the MySQL account to use when invoking
  16494.      `mysqladmin'.  Note that the password value is not optional for
  16495.      this option, unlike for other MySQL programs.
  16496.  
  16497. `--tcp-ip'
  16498.      Connect to each MySQL server via the TCP/IP port instead of the
  16499.      Unix socket file.  (If a socket file is missing, the server might
  16500.      still be running, but accessible only via the TCP/IP port.)  By
  16501.      default, connections are made using the Unix socket file.  This
  16502.      option affects `stop' and `report' operations.
  16503.  
  16504. `--user=USER_NAME'
  16505.      The username of the MySQL account to use when invoking
  16506.      `mysqladmin'.
  16507.  
  16508. `--version'
  16509.      Display version information and exit.
  16510.  
  16511. Some notes about `mysqld_multi':
  16512.  
  16513.    * Make sure that the MySQL account used for stopping the `mysqld'
  16514.      servers (with the `mysqladmin' program) has the same username and
  16515.      password for each server. Also, make sure that the account has the
  16516.      `SHUTDOWN' privilege. If the servers that you want to manage have
  16517.      many different usernames or passwords for the administrative
  16518.      accounts, you might want to create an account on each server that
  16519.      has the same username and password.  For example, you might set up
  16520.      a common `multi_admin' account by executing the following commands
  16521.      for each server:
  16522.  
  16523.           shell> mysql -u root -S /tmp/mysql.sock -pROOT_PASSWORD
  16524.           mysql> GRANT SHUTDOWN ON *.*
  16525.               -> TO 'multi_admin'@'localhost' IDENTIFIED BY 'multipass';
  16526.  
  16527.      *Note Privileges::.  You will have to do this for each `mysqld'
  16528.      server. Change the connection parameters appropriately when
  16529.      connecting to each one.  Note that the host part of the account
  16530.      name must allow you to connect as `multi_admin' from the host
  16531.      where you want to run `mysqld_multi'.
  16532.  
  16533.    * The `--pid-file' option is very important if you are using
  16534.      `mysqld_safe' to start `mysqld' (for example,
  16535.      `--mysqld=mysqld_safe') Every `mysqld' should have its own process
  16536.      ID file. The advantage of using `mysqld_safe' instead of `mysqld'
  16537.      is that `mysqld_safe' "guards" its `mysqld' process and will
  16538.      restart it if the process terminates due to a signal sent using
  16539.      `kill -9', or for other reasons, such as a segmentation fault.
  16540.      Please note that the `mysqld_safe' script might require that you
  16541.      start it from a certain place. This means that you might have to
  16542.      change location to a certain directory before running
  16543.      `mysqld_multi'. If you have problems starting, please see the
  16544.      `mysqld_safe' script. Check especially the lines:
  16545.  
  16546.           ----------------------------------------------------------------
  16547.           MY_PWD=`pwd`
  16548.           # Check if we are starting this relative (for the binary release)
  16549.           if test -d $MY_PWD/data/mysql -a -f ./share/mysql/english/errmsg.sys -a \
  16550.            -x ./bin/mysqld
  16551.           ----------------------------------------------------------------
  16552.  
  16553.      *Note `mysqld_safe': mysqld_safe.  The test performed by these
  16554.      lines should be successful, or you might encounter problems.
  16555.  
  16556.    * The Unix socket file and the TCP/IP port number must be different
  16557.      for every `mysqld'.
  16558.  
  16559.    * You might want to use the `--user' option for `mysqld', but in
  16560.      order to do this you need to run the `mysqld_multi' script as the
  16561.      Unix `root' user. Having the option in the option file doesn't
  16562.      matter; you will just get a warning, if you are not the superuser
  16563.      and the `mysqld' processes are started under your own Unix account.
  16564.  
  16565.    * *Important*: Make sure that the data directory is fully accessible
  16566.      to the Unix account that the specific `mysqld' process is started
  16567.      as. _Do not_ use the Unix root account for this, unless you _know_
  16568.      what you are doing.
  16569.  
  16570.    * *Most important*: Before using `mysqld_multi' be sure that you
  16571.      understand the meanings of the options that are passed to the
  16572.      `mysqld' servers and _why_ you would want to have separate `mysqld'
  16573.      processes.  Beware of the dangers of using multiple `mysqld'
  16574.      servers with the same data directory.  Use separate data
  16575.      directories, unless you _know_ what you are doing.  Starting
  16576.      multiple servers with the same data directory _will not_ give you
  16577.      extra performance in a threaded system.  *Note Multiple servers::.
  16578.  
  16579.  
  16580. The following example shows how you might set up an option file for use
  16581. with `mysqld_multi'.  The first and fifth `[mysqld#]' group were
  16582. intentionally left out from the example to illustrate that you can have
  16583. "gaps" in the option file. This gives you more flexibility.  The order
  16584. in which the `mysqld' programs are started or stopped depends on the
  16585. order in which they appear in the option file.
  16586.  
  16587.      # This file should probably be in your home dir (~/.my.cnf)
  16588.      # or /etc/my.cnf
  16589.      # Version 2.1 by Jani Tolonen
  16590.      
  16591.      [mysqld_multi]
  16592.      mysqld     = /usr/local/bin/mysqld_safe
  16593.      mysqladmin = /usr/local/bin/mysqladmin
  16594.      user       = multi_admin
  16595.      password   = multipass
  16596.      
  16597.      [mysqld2]
  16598.      socket     = /tmp/mysql.sock2
  16599.      port       = 3307
  16600.      pid-file   = /usr/local/mysql/var2/hostname.pid2
  16601.      datadir    = /usr/local/mysql/var2
  16602.      language   = /usr/local/share/mysql/english
  16603.      user       = john
  16604.      
  16605.      [mysqld3]
  16606.      socket     = /tmp/mysql.sock3
  16607.      port       = 3308
  16608.      pid-file   = /usr/local/mysql/var3/hostname.pid3
  16609.      datadir    = /usr/local/mysql/var3
  16610.      language   = /usr/local/share/mysql/swedish
  16611.      user       = monty
  16612.      
  16613.      [mysqld4]
  16614.      socket     = /tmp/mysql.sock4
  16615.      port       = 3309
  16616.      pid-file   = /usr/local/mysql/var4/hostname.pid4
  16617.      datadir    = /usr/local/mysql/var4
  16618.      language   = /usr/local/share/mysql/estonia
  16619.      user       = tonu
  16620.      
  16621.      [mysqld6]
  16622.      socket     = /tmp/mysql.sock6
  16623.      port       = 3311
  16624.      pid-file   = /usr/local/mysql/var6/hostname.pid6
  16625.      datadir    = /usr/local/mysql/var6
  16626.      language   = /usr/local/share/mysql/japanese
  16627.      user       = jani
  16628.  
  16629. *Note Option files::.
  16630.  
  16631. Configuring the MySQL Server
  16632. ============================
  16633.  
  16634. This section discusses MySQL server configuration topics:
  16635.  
  16636.    * Startup options that the server supports
  16637.  
  16638.    * How to set the server SQL mode
  16639.  
  16640.    * Server system variables
  16641.  
  16642.    * Server status variables
  16643.  
  16644. `mysqld' Command-Line Options
  16645. -----------------------------
  16646.  
  16647. When you start the `mysqld' server, you can specify program options
  16648. using any of the methods described in *Note Program Options::. The most
  16649. common methods are to provide options in an option file or on the
  16650. command line. However, in most cases it is desirable to make sure that
  16651. the server uses the same options each time it runs. The best way to
  16652. ensure this is to list them in an option file.  *Note Option files::.
  16653.  
  16654. `mysqld' reads options from the `[mysqld]' and `[server]' groups.
  16655. `mysqld_safe' reads options from the `[mysqld]', `[server]',
  16656. `[mysqld_safe]', and `[safe_mysqld]' groups.  `mysql.server' reads
  16657. options from the `[mysqld]' and `[mysql.server]' groups.  An embedded
  16658. MySQL server usually reads options from the `[server]', `[embedded]',
  16659. and `[XXXXX_SERVER]' groups, where XXXXX is the name of the application
  16660. into which the server is embedded.
  16661.  
  16662. `mysqld' accepts many command-line options.  For a list, execute
  16663. `mysqld --help'. Before MySQL 4.1.1, `--help' prints the full help
  16664. message. As of 4.1.1, it prints a brief message; to see the full list,
  16665. use `mysqld --verbose --help'.
  16666.  
  16667. The following list shows some of the most common server options.
  16668. Additional options are described elsewhere:
  16669.  
  16670.    * Options that affect security: See *Note Privileges options::.
  16671.  
  16672.    * SSL-related options: See *Note SSL options::.
  16673.  
  16674.    * Binary log control options: See *Note Binary log::.
  16675.  
  16676.    * Replication-related options: See *Note Replication Options::.
  16677.  
  16678.    * Options specific to particular storage engines: See *Note `MyISAM'
  16679.      start: MyISAM start, *Note `BDB' start: BDB start, *Note `InnoDB'
  16680.      start: InnoDB start.
  16681.  
  16682.  
  16683. You can also set the value of a server system variable by using the
  16684. variable name as an option, as described later in this section.
  16685.  
  16686. `--help, -?'
  16687.      Display a short help message and exit.  Before MySQL 4.1.1,
  16688.      `--help' displays the full help message.  As of 4.1.1, it displays
  16689.      an abbreviated message only.  Use both the `--verbose' and
  16690.      `--help' options to see the full message.
  16691.  
  16692. `--ansi'
  16693.      Use standard SQL syntax instead of MySQL syntax.  *Note ANSI
  16694.      mode::.  For more precise control over the server SQL mode, use
  16695.      the `--sql-mode' option instead.
  16696.  
  16697. `--basedir=PATH, -b PATH'
  16698.      The path to the MySQL installation directory. All paths are
  16699.      usually resolved relative to this.
  16700.  
  16701. `--big-tables'
  16702.      Allow large result sets by saving all temporary sets in files.
  16703.      This option prevents most "table full" errors, but also slows down
  16704.      queries for which in-memory tables would suffice.  Since MySQL
  16705.      3.23.2, the server is able to handle large result sets
  16706.      automatically by using memory for small temporary tables and
  16707.      switching to disk tables where necessary.
  16708.  
  16709. `--bind-address=IP'
  16710.      The IP address to bind to.
  16711.  
  16712. `--console'
  16713.      Write the error log messages to stderr/stdout even if `--log-error'
  16714.      is specified.  On Windows, `mysqld' will not close the console
  16715.      screen if this option is used.
  16716.  
  16717. `--character-sets-dir=PATH'
  16718.      The directory where character sets are installed.  *Note Character
  16719.      sets::.
  16720.  
  16721. `--chroot=PATH'
  16722.      Put the `mysqld' server in a closed environment during startup by
  16723.      using the `chroot()' system call. This is a recommended security
  16724.      measure as of MySQL 4.0. (MySQL 3.23 is not able to provide a
  16725.      `chroot()' jail that is 100% closed.)  Note that use of this
  16726.      option somewhat limits `LOAD DATA INFILE' and `SELECT ... INTO
  16727.      OUTFILE'.
  16728.  
  16729. `--core-file'
  16730.      Write a core file if `mysqld' dies.  For some systems, you must
  16731.      also specify the `--core-file-size' option to `mysqld_safe'.
  16732.      *Note `mysqld_safe': mysqld_safe.  Note that on some systems, such
  16733.      as Solaris, you will not get a core file if you are also using the
  16734.      `--user' option.
  16735.  
  16736. `--datadir=PATH, -h PATH'
  16737.      The path to the data directory.
  16738.  
  16739. `--debug[=DEBUG_OPTIONS], -# [DEBUG_OPTIONS]'
  16740.      If MySQL is configured with `--with-debug', you can use this
  16741.      option to get a trace file of what `mysqld' is doing.  The
  16742.      DEBUG_OPTIONS string often is `'d:t:o,FILE_NAME''.  *Note Making
  16743.      trace files::.
  16744.  
  16745. `--default-character-set=CHARSET'
  16746.      Use CHARSET as the default character set.  *Note Character sets::.
  16747.  
  16748. `--default-collation=COLLATION'
  16749.      Use COLLATION as the default collation.  This option is available
  16750.      as of MySQL 4.1.1.  *Note Character sets::.
  16751.  
  16752. `--default-storage-engine=TYPE'
  16753.      This option is a synonym for `--default-table-type'.  It is
  16754.      available as of MySQL 4.1.2.
  16755.  
  16756. `--default-table-type=TYPE'
  16757.      Set the default table type for tables.  *Note Table types::.
  16758.  
  16759. `--default-time-zone=TYPE'
  16760.      Set the default server time zone.  This option sets the global
  16761.      `time_zone' system variable.  If this option is not given, the
  16762.      default time zone will be the same as the system time zone (given
  16763.      by the value of the `system_time_zone' system variable.  This
  16764.      option is available as of MySQL 4.1.3.
  16765.  
  16766. `--delay-key-write[= OFF | ON | ALL]'
  16767.      How the `DELAYED KEYS' option should be used.  Delayed key writing
  16768.      causes key buffers not to be flushed between writes for `MyISAM'
  16769.      tables.  `OFF' disables delayed key writes.  `ON' enables delayed
  16770.      key writes for those tables that were created with the `DELAYED
  16771.      KEYS' option.  `ALL' delays key writes for all `MyISAM' tables.
  16772.      Available as of MySQL 4.0.3.  *Note Server parameters::. *Note
  16773.      MyISAM start::.
  16774.  
  16775.      *Note*: If you set this variable to `ALL', you should not use
  16776.      `MyISAM' tables from within another program (such as from another
  16777.      MySQL server or with `myisamchk') when the table is in use. Doing
  16778.      so will lead to index corruption.
  16779.  
  16780. `--delay-key-write-for-all-tables'
  16781.      Old form of `--delay-key-write=ALL' for use prior to MySQL 4.0.3.
  16782.      As of 4.0.3, use `--delay-key-write' instead.
  16783.  
  16784. `--des-key-file=FILE_NAME'
  16785.      Read the default keys used by `DES_ENCRYPT()' and `DES_DECRYPT()'
  16786.      from this file.
  16787.  
  16788. `--enable-named-pipe'
  16789.      Enable support for named pipes.  This option applies only on
  16790.      Windows NT, 2000, and XP systems, and can be used only with the
  16791.      `mysqld-nt' and `mysqld-max-nt' servers that support named pipe
  16792.      connections.
  16793.  
  16794. `--exit-info[=FLAGS], -T [FLAGS]'
  16795.      This is a bit mask of different flags you can use for debugging the
  16796.      `mysqld' server. Do not use this option unless you know exactly
  16797.      what it does!
  16798.  
  16799. `--external-locking'
  16800.      Enable system locking.  Note that if you use this option on a
  16801.      system on which `lockd' does not fully work (as on Linux), you
  16802.      will easily get `mysqld' to deadlock.  This option previously was
  16803.      named `--enable-locking'.
  16804.  
  16805.      *Note*: If you use this option to enable updates to `MyISAM'
  16806.      tables from many MySQL processes, you have to ensure that these
  16807.      conditions are satisfied:
  16808.  
  16809.         * You should not use the query cache for queries that use
  16810.           tables that are updated by another process.
  16811.  
  16812.         * You should not use `--delay-key-write=ALL' or
  16813.           `DELAY_KEY_WRITE=1' on any shared tables.
  16814.  
  16815.      The easiest way to ensure this is to always use
  16816.      `--external-locking' together with `--delay-key-write=OFF
  16817.      --query-cache-size=0'.
  16818.  
  16819.      (This is not done by default because in many setups it's useful to
  16820.      have a mixture of the above options.)
  16821.  
  16822. `--flush'
  16823.      Flush all changes to disk after each SQL statement.  Normally MySQL
  16824.      does a write of all changes to disk only after each SQL statement
  16825.      and lets the operating system handle the synching to disk.  *Note
  16826.      Crashing::.
  16827.  
  16828. `--init-file=FILE'
  16829.      Read SQL statements from this file at startup.  Each statement
  16830.      must be on a single line and should not include comments.
  16831.  
  16832. `--innodb-safe-binlog'
  16833.      Adds consistency guarantees between the content of `InnoDB' tables
  16834.      and the binary log.  *Note Binary log::.
  16835.  
  16836. `--language=LANG_NAME, -L LANG_NAME'
  16837.      Client error messages in given language.  LANG_NAME can be given
  16838.      as the language name or as the full pathname to the directory
  16839.      where the language files are installed.  *Note Languages::.
  16840.  
  16841. `--log[=FILE], -l [FILE]'
  16842.      Log connections and queries to this file. *Note Query log::. If
  16843.      you don't specify a filename, MySQL will use `HOST_NAME.log' as
  16844.      the filename.
  16845.  
  16846. `--log-bin=[FILE]'
  16847.      The binary log file.  Log all queries that change data to this
  16848.      file. Used for backup and replication.  *Note Binary log::.  If
  16849.      you don't specify a filename, MySQL will use `HOST_NAME-bin' as
  16850.      the filename.
  16851.  
  16852. `--log-bin-index[=FILE]'
  16853.      The index file for binary log filenames. *Note Binary log::.  If
  16854.      you don't specify a filename, MySQL will use `HOST_NAME-bin.index'
  16855.      as the filename.
  16856.  
  16857. `--log-error[=FILE]'
  16858.      Log errors and startup messages to this file. *Note Error log::.
  16859.      If you don't specify a filename, MySQL will use `HOST_NAME.err' as
  16860.      the filename.
  16861.  
  16862. `--log-isam[=FILE]'
  16863.      Log all `ISAM'/`MyISAM' changes to this file (used only when
  16864.      debugging `ISAM'/`MyISAM').
  16865.  
  16866. `--log-long-format'
  16867.      Log some extra information to the log files (update log, binary
  16868.      update log, and slow queries log, whatever log has been
  16869.      activated). For example, username and timestamp are logged for
  16870.      queries. If you are using `--log-slow-queries' and
  16871.      `--log-long-format', queries that are not using indexes also are
  16872.      logged to the slow query log.  Note that `--log-long-format' is
  16873.      deprecated as of MySQL version 4.1, when `--log-short-format' was
  16874.      introduced (the long log format is the default setting since
  16875.      version 4.1). Also note that starting with MySQL 4.1, the
  16876.      `--log-queries-not-using-indexes' option is available for the
  16877.      purpose of logging queries that do not use indexes to the slow
  16878.      query log.
  16879.  
  16880. `--log-queries-not-using-indexes'
  16881.      If you are using this option with `--log-slow-queries', then
  16882.      queries that are not using indexes also  are logged to the slow
  16883.      query log. This option is available as of MySQL 4.1. *Note Slow
  16884.      query log::.
  16885.  
  16886. `--log-short-format'
  16887.      Log less information to the log files (update log, binary update
  16888.      log, and slow queries log, whatever log has been activated). For
  16889.      example, username and timestamp are not logged for queries. This
  16890.      option was introduced in MySQL 4.1.
  16891.  
  16892. `--log-slow-queries[=FILE]'
  16893.      Log all queries that have taken more than `long_query_time' seconds
  16894.      to execute to this file.  *Note Slow query log::.  Note that the
  16895.      default for the amount of information logged has changed in MySQL
  16896.      4.1. See the `--log-long-format' and `--log-short-format' options
  16897.      for details.
  16898.  
  16899. `--log-update[=FILE]'
  16900.      Log updates to FILE# where # is a unique number if not given.
  16901.      *Note Update log::. The update log is deprecated and is removed in
  16902.      MySQL 5.0.0; you should use the binary log instead (`--log-bin').
  16903.      *Note Binary log::. Starting from version 5.0.0, using
  16904.      `--log-update' will just turn on the binary log instead (*note
  16905.      News-5.0.0::).
  16906.  
  16907. `--log-warnings, -W'
  16908.      Print out warnings such as `Aborted connection...' to the error
  16909.      log.  Enabling this option is recommended, for example, if you use
  16910.      replication (you will get more information about what is happening,
  16911.      such as messages about network failures and reconnections).  This
  16912.      option is enabled by default as of MySQL 4.0.19 and 4.1.2; to
  16913.      disable it, use `--skip-log-warnings'.  As of MySQL 4.0.21 and
  16914.      4.1.3, aborted connections are not logged to the error log unless
  16915.      the value is greater than 1.  *Note Communication errors::.
  16916.  
  16917.      This option was named `--warnings' before MySQL 4.0.
  16918.  
  16919. `--low-priority-updates'
  16920.      Table-modifying operations (`INSERT', `REPLACE', `DELETE',
  16921.      `UPDATE') will have lower priority than selects.  This can also be
  16922.      done via `{INSERT | REPLACE | DELETE | UPDATE} LOW_PRIORITY ...'
  16923.      to lower the priority of only one query, or by `SET
  16924.      LOW_PRIORITY_UPDATES=1' to change the priority in one thread.
  16925.      *Note Table locking::.
  16926.  
  16927. `--memlock'
  16928.      Lock the `mysqld' process in memory.  This works on systems such as
  16929.      Solaris that support the `mlockall()' system call.  This might
  16930.      help if you have a problem where the operating system is causing
  16931.      `mysqld' to swap on disk.  Note that use of this option requires
  16932.      that you run the server as `root', which is normally not a good
  16933.      idea for security reasons.
  16934.  
  16935. `--myisam-recover [=OPTION[,OPTION...]]]'
  16936.      Set the `MyISAM' storage engine recovery mode.  The option value
  16937.      is any combination of the values of `DEFAULT', `BACKUP', `FORCE',
  16938.      or `QUICK'.  If you specify multiple values, separate them by
  16939.      commas.  You can also use a value of `""' to disable this option.
  16940.      If this option is used, `mysqld' will, when it opens a `MyISAM'
  16941.      table, open check whether the table is marked as crashed or wasn't
  16942.      closed properly.  (The last option works only if you are running
  16943.      with `--skip-external-locking'.)  If this is the case, `mysqld'
  16944.      will run a check on the table. If the table was corrupted,
  16945.      `mysqld' will attempt to repair it.
  16946.  
  16947.      The following options affect how the repair works:
  16948.  
  16949.      *Option*   *Description*
  16950.      `DEFAULT'  The same as not giving any option to
  16951.                          `--myisam-recover'.
  16952.      `BACKUP'   If the data file was changed during recovery,
  16953.                 save a                     backup of the
  16954.                 `TBL_NAME.MYD' file as
  16955.                 `TBL_NAME-DATETIME.BAK'.
  16956.      `FORCE'    Run recovery even if we will lose more than
  16957.                 one row                     from the `.MYD'
  16958.                 file.
  16959.      `QUICK'    Don't check the rows in the table if there
  16960.                 aren't any                     delete blocks.
  16961.  
  16962.      Before a table is automatically repaired, MySQL will add a note
  16963.      about this in the error log.  If you want to be able to recover
  16964.      from most problems without user intervention, you should use the
  16965.      options `BACKUP,FORCE'.  This will force a repair of a table even
  16966.      if some rows would be deleted, but it will keep the old data file
  16967.      as a backup so that you can later examine what happened.
  16968.  
  16969.      This option is available as of MySQL 3.23.25.
  16970.  
  16971. `--ndbcluster'
  16972.      If the binary includes support for the `NDBCluster' storage engine
  16973.      (from version 4.1.3, the MySQL-Max binaries are built with
  16974.      `NDBCluster' enabled) the default disabling of support for the
  16975.      `NDBCluster' storage engine can be overruled by using this option.
  16976.      Using the `NDBCluster' storage engine is necessary for using MySQL
  16977.      Cluster.  *Note NDBCluster::.
  16978.  
  16979. `--new'
  16980.      The `--new' option can be used to make the server behave as 4.1 in
  16981.      certain respects, easing a 4.0 to 4.1 upgrade:
  16982.         * Hexadecimal strings such as `0xFF' are treated as strings by
  16983.           default rather than as numbers.  (Works in 4.0.12 and up.)
  16984.  
  16985.         * `TIMESTAMP' is returned as a string with the format
  16986.           `'YYYY-MM-DD HH:MM:SS''.  (Works in 4.0.13 and up.)  *Note
  16987.           Column types::.
  16988.  
  16989.      This option can be used to help you see how your applications will
  16990.      behave in MySQL 4.1, without actually upgrading to 4.1.
  16991.  
  16992. `--pid-file=PATH'
  16993.      The path to the process ID file used by `mysqld_safe'.
  16994.  
  16995. `--port=PORT_NUM, -P PORT_NUM'
  16996.      The port number to use when listening for TCP/IP connections.
  16997.  
  16998. `--old-protocol, -o'
  16999.      Use the 3.20 protocol for compatibility with some very old clients.
  17000.      *Note Upgrading-from-3.20::.
  17001.  
  17002. `--one-thread'
  17003.      Only use one thread (for debugging under Linux).  This option is
  17004.      available only if the server is built with debugging enabled.
  17005.      *Note Debugging server::.
  17006.  
  17007. `--open-files-limit=COUNT'
  17008.      To change the number of file descriptors available to `mysqld'.
  17009.      If this is not set or set to 0, then `mysqld' will use this value
  17010.      to reserve file descriptors to use with `setrlimit()'.  If this
  17011.      value is 0 then `mysqld' will reserve `max_connections*5' or
  17012.      `max_connections + table_cache*2' (whichever is larger) number of
  17013.      files.  You should try increasing this if `mysqld' gives you the
  17014.      error "Too many open files."
  17015.  
  17016. `--safe-mode'
  17017.      Skip some optimization stages.
  17018.  
  17019. `--safe-show-database'
  17020.      With this option, the `SHOW DATABASES' statement displays only the
  17021.      names of those databases for which the user has some kind of
  17022.      privilege.  As of MySQL 4.0.2, this option is deprecated and
  17023.      doesn't do anything (it is enabled by default), because there is
  17024.      now a `SHOW DATABASES' privilege that can be used to control
  17025.      access to database names on a per-account basis.  *Note Privileges
  17026.      provided::.
  17027.  
  17028. `--safe-user-create'
  17029.      If this is enabled, a user can't create new users with the `GRANT'
  17030.      statement, if the user doesn't have the `INSERT' privilege for the
  17031.      `mysql.user' table or any column in the table.
  17032.  
  17033. `--secure-auth'
  17034.      Disallow authentication for accounts that have old (pre-4.1)
  17035.      passwords.  This option is available as of MySQL 4.1.1.
  17036.  
  17037. `--shared-memory'
  17038.      Enable shared-memory connections by local clients. This option is
  17039.      available only on Windows. It was added in MySQL 4.1.0.
  17040.  
  17041. `--shared-memory-base-name=NAME'
  17042.      The name to use for shared-memory connections.  This option is
  17043.      available only on Windows. It was added in MySQL 4.1.0.
  17044.  
  17045. `--skip-bdb'
  17046.      Disable the `BDB' storage engine. This saves memory and might speed
  17047.      up some operations.  Do not use this option if you require `BDB'
  17048.      tables.
  17049.  
  17050. `--skip-concurrent-insert'
  17051.      Turn off the ability to select and insert at the same time on
  17052.      `MyISAM' tables. (This is to be used only if you think you have
  17053.      found a bug in this feature.)
  17054.  
  17055. `--skip-delay-key-write'
  17056.      Ignore the `DELAY_KEY_WRITE' option for all tables.  As of MySQL
  17057.      4.0.3, you should use `--delay-key-write=OFF' instead.  *Note
  17058.      Server parameters::.
  17059.  
  17060. `--skip-external-locking'
  17061.      Don't use system locking.  To use `isamchk' or `myisamchk', you
  17062.      must shut down the server.  *Note Stability::.  In MySQL 3.23, you
  17063.      can use `CHECK TABLE' and `REPAIR TABLE' to check and repair
  17064.      `MyISAM' tables.  This option previously was named
  17065.      `--skip-locking'.
  17066.  
  17067. `--skip-grant-tables'
  17068.      This option causes the server not to use the privilege system at
  17069.      all. This gives everyone _full access_ to all databases!  (You can
  17070.      tell a running server to start using the grant tables again by
  17071.      executing a `mysqladmin flush-privileges' or `mysqladmin reload'
  17072.      command, or by issuing a `FLUSH PRIVILEGES' statement.)
  17073.  
  17074. `--skip-host-cache'
  17075.      Do not use the internal hostname cache for faster name-to-IP
  17076.      resolution.  Instead, query the DNS server every time a client
  17077.      connects.  *Note DNS::.
  17078.  
  17079. `--skip-innodb'
  17080.      Disable the `InnoDB' storage engine.  This saves memory and disk
  17081.      space and might speed up some operations.  Do not use this option
  17082.      if you require `InnoDB' tables.
  17083.  
  17084. `--skip-isam'
  17085.      Disable the `ISAM' storage engine.  As of MySQL 4.1, `ISAM' is
  17086.      disabled by default, so this option applies only if the server was
  17087.      configured with support for `ISAM'.  This option was added in
  17088.      MySQL 4.1.1.
  17089.  
  17090. `--skip-name-resolve'
  17091.      Do not resolve hostnames when checking client connections. Use
  17092.      only IP numbers. If you use this option, all `Host' column values
  17093.      in the grant tables must be IP numbers or `localhost'.  *Note
  17094.      DNS::.
  17095.  
  17096. `--skip-ndbcluster'
  17097.      Disable the `NDBCluster' storage engine. This is the default for
  17098.      binaries that were built with `NDBCluster' storage engine support,
  17099.      this means that the system will only allocate memory and other
  17100.      resources for this storage engine if it is explicitly enabled.
  17101.  
  17102. `--skip-networking'
  17103.      Don't listen for TCP/IP connections at all.  All interaction with
  17104.      `mysqld' must be made via named pipes (on Windows) or Unix socket
  17105.      files (on Unix).  This option is highly recommended for systems
  17106.      where only local clients are allowed.  *Note DNS::.
  17107.  
  17108. `--skip-new'
  17109.      Don't use new, possibly wrong routines.
  17110.  
  17111. `--skip-symlink'
  17112.      This is the old form of `--skip-symbolic-links', for use before
  17113.      MySQL 4.0.13.
  17114.  
  17115. `--symbolic-links, --skip-symbolic-links'
  17116.      Enable or disable symbolic link support. This option has different
  17117.      effects on Windows and Unix:
  17118.  
  17119.         * On Windows, enabling symbolic links allows you to establish a
  17120.           symbolic link to a database directory by creating a
  17121.           `directory.sym' file that contains the path to the real
  17122.           directory.  *Note Windows symbolic links::.
  17123.  
  17124.         * On Unix, enabling symbolic links means that you can link a
  17125.           `MyISAM' index file or data file to another directory with
  17126.           the `INDEX DIRECTORY' or `DATA DIRECTORY' options of the
  17127.           `CREATE TABLE' statement.  If you delete or rename the table,
  17128.           the files that its symbolic links point to also are deleted or
  17129.           renamed. *Note `CREATE TABLE': CREATE TABLE.
  17130.  
  17131.      This option was added in MySQL 4.0.13.
  17132.  
  17133. `--skip-safemalloc'
  17134.      If MySQL is configured with `--with-debug=full', all MySQL programs
  17135.      check for memory overruns during each memory allocation and memory
  17136.      freeing operation.  This checking is very slow, so for the server
  17137.      you can avoid it when you don't need it by using the
  17138.      `--skip-safemalloc' option.
  17139.  
  17140. `--skip-show-database'
  17141.      With this option, the `SHOW DATABASES' statement is allowed only to
  17142.      users who have the `SHOW DATABASES' privilege, and the statement
  17143.      displays all database names.  Without this option, `SHOW
  17144.      DATABASES' is allowed to all users, but displays each database
  17145.      name only if the user has the `SHOW DATABASES' privilege or some
  17146.      privilege for the database.
  17147.  
  17148. `--skip-stack-trace'
  17149.      Don't write stack traces.  This option is useful when you are
  17150.      running `mysqld' under a debugger. On some systems, you also must
  17151.      use this option to get a core file. *Note Debugging server::.
  17152.  
  17153. `--skip-thread-priority'
  17154.      Disable using thread priorities for faster response time.
  17155.  
  17156. `--socket=PATH'
  17157.      On Unix, this option specifies the Unix socket file to use for
  17158.      local connections. The default value is `/tmp/mysql.sock'.  On
  17159.      Windows, the option specifies the pipe name to use for local
  17160.      connections that use a named pipe. The default value is `MySQL'.
  17161.  
  17162. `--sql-mode=VALUE[,VALUE[,VALUE...]]'
  17163.      Set the SQL mode for MySQL. *Note Server SQL mode::. This option
  17164.      was added in 3.23.41.
  17165.  
  17166. `--temp-pool'
  17167.      This option causes most temporary files created by the server to
  17168.      use a small set of names, rather than a unique name for each new
  17169.      file. This works around a problem in the Linux kernel dealing with
  17170.      creating many new files with different names. With the old
  17171.      behavior, Linux seems to "leak" memory, because it's being
  17172.      allocated to the directory entry cache rather than to the disk
  17173.      cache.
  17174.  
  17175. `--transaction-isolation=LEVEL'
  17176.      Sets the default transaction isolation level, which can be
  17177.      `READ-UNCOMMITTED', `READ-COMMITTED', `REPEATABLE-READ', or
  17178.      `SERIALIZABLE'.  *Note `SET TRANSACTION': SET TRANSACTION.
  17179.  
  17180. `--tmpdir=PATH, -t PATH'
  17181.      The path of the directory to use for creating temporary files. It
  17182.      might be useful if your default `/tmp' directory resides on a
  17183.      partition that is too small to hold temporary tables.  Starting
  17184.      from MySQL 4.1, this option accepts several paths that are used in
  17185.      round-robin fashion. Paths should be separated by colon characters
  17186.      (`:') on Unix and semicolon characters (`;') on Windows, NetWare,
  17187.      and OS/2.  If the MySQL server is acting as a replication slave,
  17188.      you should not set `--tmpdir' to point to a directory on a
  17189.      memory-based filesystem or to a directory that is cleared when the
  17190.      server host restarts.  A replication slave needs some of its
  17191.      temporary files to survive a machine restart so that it can
  17192.      replicate temporary tables or `LOAD DATA INFILE' operations. If
  17193.      files in the temporary file directory are lost when the server
  17194.      restarts, replication will fail.
  17195.  
  17196. `--user={USER_NAME | USER_ID}, -u {USER_NAME | USER_ID}'
  17197.      Run the `mysqld' server as the user having the name USER_NAME or
  17198.      the numeric user ID USER_ID.  ("User" in this context refers to a
  17199.      system login account, not a MySQL user listed in the grant tables.)
  17200.  
  17201.      This option is _mandatory_ when starting `mysqld' as `root'.  The
  17202.      server will change its user ID during its startup sequence,
  17203.      causing it to run as that particular user rather than as `root'.
  17204.      *Note Security guidelines::.
  17205.  
  17206.      Starting from MySQL 3.23.56 and 4.0.12: To avoid a possible
  17207.      security hole where a user adds a `--user=root' option to some
  17208.      `my.cnf' file (thus causing the server to run as `root'), `mysqld'
  17209.      uses only the first `--user' option specified and produces a
  17210.      warning if there are multiple `--user' options. Options in
  17211.      `/etc/my.cnf' and `datadir/my.cnf' are processed before
  17212.      command-line options, so it is recommended that you put a `--user'
  17213.      option in `/etc/my.cnf' and specify a value other than `root'. The
  17214.      option in `/etc/my.cnf' will be found before any other `--user'
  17215.      options, which ensures that the server runs as a user other than
  17216.      `root', and that a warning results if any other `--user' option is
  17217.      found.
  17218.  
  17219. `--version, -V'
  17220.      Display version information and exit.
  17221.  
  17222. You can assign a value to a server system variable by using an option of
  17223. the form `--VAR_NAME=VALUE'. For example, `--key_buffer_size=32M' sets
  17224. the `key_buffer_size' variable to a value of 32MB.
  17225.  
  17226. Note that when setting a variable to a value, MySQL might automatically
  17227. correct it to stay within a given range, or adjust the value to the
  17228. closest allowable value if only certain values are allowed.
  17229.  
  17230. It is also possible to set variables by using
  17231. `--set-variable=VAR_NAME=VALUE' or `-O VAR_NAME=VALUE' syntax. However,
  17232. this syntax is deprecated as of MySQL 4.0.
  17233.  
  17234. You can find a full description for all variables in *Note Server
  17235. system variables::.  The section on tuning server parameters includes
  17236. information on how to optimize them.  *Note Server parameters::.
  17237.  
  17238. You can change the values of most system variables for a running server
  17239. with the `SET' statement. *Note `SET OPTION': SET OPTION.
  17240.  
  17241. If you want to restrict the maximum value that a startup option can be
  17242. set to with `SET', you can define this by using the
  17243. `--maximum-VAR_NAME' command-line option.
  17244.  
  17245. The Server SQL Mode
  17246. -------------------
  17247.  
  17248. The MySQL server can operate in different SQL modes, and (as of MySQL
  17249. 4.1) can apply these modes differentially for different clients. This
  17250. allows applications to tailor server operation to their own
  17251. requirements.
  17252.  
  17253. Modes define what SQL syntax MySQL should support and what kind of data
  17254. validation checks it should perform.  This makes it easier to use MySQL
  17255. in different environments and to use MySQL together with other database
  17256. servers.
  17257.  
  17258. You can set the default SQL mode by starting `mysqld' with the
  17259. `--sql-mode="modes"' option. Beginning with MySQL 4.1, you can also
  17260. change the mode after startup time by setting the `sql_mode' variable
  17261. with a `SET [SESSION|GLOBAL] sql_mode='modes'' statement.  Setting the
  17262. `GLOBAL' variable affects the operation of all clients that connect
  17263. from that time on. Setting the `SESSION' variable affects only the
  17264. current client.  `modes' is a list of different modes separated by
  17265. comma (`,') characters.  You can retrieve the current mode by issuing a
  17266. `SELECT @@sql_mode' statement. The default value is empty (no modes
  17267. set).
  17268.  
  17269. The value also can be empty (`--sql-mode=""') if you want to reset it.
  17270.  
  17271. The following list describes the supported modes:
  17272.  
  17273. `ANSI_QUOTES'
  17274.      Treat `"' as an identifier quote character (like the ``' quote
  17275.      character) and not as a string quote character. You can still use
  17276.      ``' to quote identifers in ANSI mode. With `ANSI_QUOTES' enabled,
  17277.      you cannot use double quotes to quote a literal string, because it
  17278.      will be interpreted as an identifier.  (New in MySQL 4.0.0.)
  17279.  
  17280. `IGNORE_SPACE'
  17281.      Allow spaces between a function name and the `(' character.  This
  17282.      forces all function names to be treated as reserved words. As a
  17283.      result, if you want to access any database, table, or column name
  17284.      that is a reserved word, you must quote it.  For example, because
  17285.      there is a `USER()' function, the name of the `user' table in the
  17286.      `mysql' database and the `User' column in that table become
  17287.      reserved, so you must quote them:
  17288.  
  17289.           SELECT "User" FROM mysql."user";
  17290.  
  17291.      (New in MySQL 4.0.0.)
  17292.  
  17293. `NO_AUTO_VALUE_ON_ZERO'
  17294.      `NO_AUTO_VALUE_ON_ZERO' affects handling of `AUTO_INCREMENT'
  17295.      columns. Normally, you generate the next sequence number for the
  17296.      column by inserting either `NULL' or `0' into it.
  17297.      `NO_AUTO_VALUE_ON_ZERO' suppresses this behavior for `0' so that
  17298.      only `NULL' generates the next sequence number. This mode can be
  17299.      useful if `0' has been stored in a table's `AUTO_INCREMENT'
  17300.      column. (This is not a recommended practice, by the way.)  For
  17301.      example, if you dump the table with `mysqldump' and then reload
  17302.      it, normally MySQL generates new sequence numbers when it
  17303.      encounters the `0' values, resulting in a table with different
  17304.      contents than the one that was dumped. Enabling
  17305.      `NO_AUTO_VALUE_ON_ZERO' before reloading the dump file solves this
  17306.      problem. As of MySQL 4.1.1, `mysqldump' automatically includes
  17307.      statements in the dump output to enable `NO_AUTO_VALUE_ON_ZERO'.
  17308.      (New in MySQL 4.1.1.)
  17309.  
  17310. `NO_DIR_IN_CREATE'
  17311.      When creating a table, ignore all `INDEX DIRECTORY' and `DATA
  17312.      DIRECTORY' directives. This option is useful on slave replication
  17313.      servers.  (New in MySQL 4.0.15.)
  17314.  
  17315. `NO_FIELD_OPTIONS'
  17316.      Don't print MySQL-specific column options in the output of `SHOW
  17317.      CREATE TABLE'. This mode is used by `mysqldump' in portability
  17318.      mode.  (New in MySQL 4.1.1.)
  17319.  
  17320. `NO_KEY_OPTIONS'
  17321.      Don't print MySQL-specific index options in the output of `SHOW
  17322.      CREATE TABLE'. This mode is used by `mysqldump' in portability
  17323.      mode.  (New in MySQL 4.1.1.)
  17324.  
  17325. `NO_TABLE_OPTIONS'
  17326.      Don't print MySQL-specific table options (such as `ENGINE') in the
  17327.      output of `SHOW CREATE TABLE'. This mode is used by `mysqldump' in
  17328.      portability mode.  (New in MySQL 4.1.1.)
  17329.  
  17330. `NO_UNSIGNED_SUBTRACTION'
  17331.      In subtraction operations, don't mark the result as `UNSIGNED' if
  17332.      one of the operands is unsigned. Note that this makes `UNSIGNED
  17333.      BIGINT' not 100% usable in all contexts. *Note Cast Functions::.
  17334.      (New in MySQL 4.0.2.)
  17335.  
  17336. `ONLY_FULL_GROUP_BY'
  17337.      Don't allow queries that in the `GROUP BY' part refer to a not
  17338.      selected column.  (New in MySQL 4.0.0.)
  17339.  
  17340. `PIPES_AS_CONCAT'
  17341.      Treat `||' as a string concatenation operator (same as `CONCAT()')
  17342.      rather than as a synonym for `OR'.  (New in MySQL 4.0.0.)
  17343.  
  17344. `REAL_AS_FLOAT'
  17345.      Treat `REAL' as a synonym for `FLOAT' rather than as a synonym for
  17346.      `DOUBLE'.  (New in MySQL 4.0.0.)
  17347.  
  17348. The following special modes are provided as shorthand for combinations
  17349. of mode values from the preceding list.  They are available as of MySQL
  17350. 4.1.1.
  17351.  
  17352. `ANSI'
  17353.      Equivalent to `REAL_AS_FLOAT', `PIPES_AS_CONCAT', `ANSI_QUOTES',
  17354.      `IGNORE_SPACE', `ONLY_FULL_GROUP_BY'. *Note ANSI mode::.
  17355.  
  17356. `DB2'
  17357.      Equivalent to `PIPES_AS_CONCAT', `ANSI_QUOTES', `IGNORE_SPACE',
  17358.      `NO_KEY_OPTIONS', `NO_TABLE_OPTIONS', `NO_FIELD_OPTIONS'.
  17359.  
  17360. `MAXDB'
  17361.      Equivalent to `PIPES_AS_CONCAT', `ANSI_QUOTES', `IGNORE_SPACE',
  17362.      `NO_KEY_OPTIONS', `NO_TABLE_OPTIONS', `NO_FIELD_OPTIONS'.
  17363.  
  17364. `MSSQL'
  17365.      Equivalent to `PIPES_AS_CONCAT', `ANSI_QUOTES', `IGNORE_SPACE',
  17366.      `NO_KEY_OPTIONS', `NO_TABLE_OPTIONS', `NO_FIELD_OPTIONS'.
  17367.  
  17368. `MYSQL323'
  17369.      Equivalent to `NO_FIELD_OPTIONS'.
  17370.  
  17371. `MYSQL40'
  17372.      Equivalent to `NO_FIELD_OPTIONS'.
  17373.  
  17374. `ORACLE'
  17375.      Equivalent to `PIPES_AS_CONCAT', `ANSI_QUOTES', `IGNORE_SPACE',
  17376.      `NO_KEY_OPTIONS', `NO_TABLE_OPTIONS', `NO_FIELD_OPTIONS'.
  17377.  
  17378. `POSTGRESQL'
  17379.      Equivalent to `PIPES_AS_CONCAT', `ANSI_QUOTES', `IGNORE_SPACE',
  17380.      `NO_KEY_OPTIONS', `NO_TABLE_OPTIONS', `NO_FIELD_OPTIONS'.
  17381.  
  17382. Server System Variables
  17383. -----------------------
  17384.  
  17385. The server maintains many system variables that indicate how it is
  17386. configured.  All of them have default values. They can be set at server
  17387. startup using options on the command line or in option files. Most of
  17388. them can be set at runtime using the `SET' statement.
  17389.  
  17390. Beginning with MySQL 4.0.3, the `mysqld' server maintains two kinds of
  17391. variables.  Global variables affect the overall operation of the server.
  17392. Session variables affect its operation for individual client
  17393. connections.
  17394.  
  17395. When the server starts, it initializes all global variables to their
  17396. default values. These defaults can be changed by options specified in
  17397. option files or on the command line.  After the server starts, those
  17398. global variables that are dynamic can be changed by connecting to the
  17399. server and issuing a `SET GLOBAL VAR_NAME' statement. To change a
  17400. global variable, you must have the `SUPER' privilege.
  17401.  
  17402. The server also maintains a set of session variables for each client
  17403. that connects. The client's session variables are initialized at connect
  17404. time using the current values of the corresponding global variables. For
  17405. those session variables that are dynamic, the client can change them by
  17406. issuing a `SET SESSION VAR_NAME' statement. Setting a session variable
  17407. requires no special privilege, but a client can change only its own
  17408. session variables, not those of any other client.
  17409.  
  17410. A change to a global variable is visible to any client that accesses
  17411. that global variable. However, it affects the corresponding session
  17412. variable that is initialized from the global variable only for clients
  17413. that connect after the change.  It does not affect the session variable
  17414. for any client that is already connected (not even that of the client
  17415. that issues the `SET GLOBAL' statement).
  17416.  
  17417. When setting a variable using a startup option, variable values can be
  17418. given with a suffix of `K', `M', or `G' to indicate kilobytes,
  17419. megabytes, or gigabytes, respectively. For example, the following
  17420. command starts the server with a key buffer size of 16 megabytes:
  17421.  
  17422.      mysqld --key_buffer_size=16M
  17423.  
  17424. Before MySQL 4.0, use this syntax instead:
  17425.  
  17426.      mysqld --set-variable=key_buffer_size=16M
  17427.  
  17428. The lettercase of suffix letters does not matter; `16M' and `16m' are
  17429. equivalent.
  17430.  
  17431. At runtime, use the `SET' statement to set system variables. In this
  17432. context, suffix letters cannot be used, but the value can take the form
  17433. of an expression:
  17434.  
  17435.      mysql> SET sort_buffer_size = 10 * 1024 * 1024;
  17436.  
  17437. To specify explicitly whether to set the global or session variable,
  17438. use the `GLOBAL' or `SESSION' options:
  17439.  
  17440.      mysql> SET GLOBAL sort_buffer_size = 10 * 1024 * 1024;
  17441.      mysql> SET SESSION sort_buffer_size = 10 * 1024 * 1024;
  17442.  
  17443. Without either option, the statement sets the session variable.
  17444.  
  17445. The variables that can be set at runtime are listed in *Note Dynamic
  17446. System Variables::.
  17447.  
  17448. If you want to restrict the maximum value to which a system variable can
  17449. be set with the `SET' statement, you can specify this maximum by using
  17450. an option of the form `--maximum-VAR_NAME' at server startup. For
  17451. example, to prevent the value of `query_cache_size' from being
  17452. increased to more than 32MB at runtime, use the option
  17453. `--maximum-query_cache_size=32M'. This feature is available as of MySQL
  17454. 4.0.2.
  17455.  
  17456. You can view system variables and their values by using the `SHOW
  17457. VARIABLES' statement.  See *Note System Variables:: for more
  17458. information.
  17459.  
  17460.      mysql> SHOW VARIABLES;
  17461.      +---------------------------------+------------------------------+
  17462.      | Variable_name                   | Value                        |
  17463.      +---------------------------------+------------------------------|
  17464.      | back_log                        | 50                           |
  17465.      | basedir                         | /usr/local/mysql             |
  17466.      | bdb_cache_size                  | 8388572                      |
  17467.      | bdb_home                        | /usr/local/mysql             |
  17468.      | bdb_log_buffer_size             | 32768                        |
  17469.      | bdb_logdir                      |                              |
  17470.      | bdb_max_lock                    | 10000                        |
  17471.      | bdb_shared_data                 | OFF                          |
  17472.      | bdb_tmpdir                      | /tmp/                        |
  17473.      | bdb_version                     | Sleepycat Software: ...      |
  17474.      | binlog_cache_size               | 32768                        |
  17475.      | bulk_insert_buffer_size         | 8388608                      |
  17476.      | character_set                   | latin1                       |
  17477.      | character_sets                  | latin1 big5 czech euc_kr     |
  17478.      | concurrent_insert               | ON                           |
  17479.      | connect_timeout                 | 5                            |
  17480.      | convert_character_set           |                              |
  17481.      | datadir                         | /usr/local/mysql/data/       |
  17482.      | default_week_format             | 0                            |
  17483.      | delay_key_write                 | ON                           |
  17484.      | delayed_insert_limit            | 100                          |
  17485.      | delayed_insert_timeout          | 300                          |
  17486.      | delayed_queue_size              | 1000                         |
  17487.      | flush                           | OFF                          |
  17488.      | flush_time                      | 0                            |
  17489.      | ft_boolean_syntax               | + -><()~*:""&|               |
  17490.      | ft_max_word_len                 | 84                           |
  17491.      | ft_min_word_len                 | 4                            |
  17492.      | ft_query_expansion_limit        | 20                           |
  17493.      | ft_stopword_file                | (built-in)                   |
  17494.      | have_bdb                        | YES                          |
  17495.      | have_innodb                     | YES                          |
  17496.      | have_isam                       | YES                          |
  17497.      | have_openssl                    | YES                          |
  17498.      | have_query_cache                | YES                          |
  17499.      | have_raid                       | NO                           |
  17500.      | have_symlink                    | DISABLED                     |
  17501.      | init_file                       |                              |
  17502.      | innodb_additional_mem_pool_size | 1048576                      |
  17503.      | innodb_buffer_pool_size         | 8388608                      |
  17504.      | innodb_data_file_path           | ibdata1:10M:autoextend       |
  17505.      | innodb_data_home_dir            |                              |
  17506.      | innodb_fast_shutdown            | ON                           |
  17507.      | innodb_file_io_threads          | 4                            |
  17508.      | innodb_flush_log_at_trx_commit  | 1                            |
  17509.      | innodb_flush_method             |                              |
  17510.      | innodb_force_recovery           | 0                            |
  17511.      | innodb_lock_wait_timeout        | 50                           |
  17512.      | innodb_log_arch_dir             |                              |
  17513.      | innodb_log_archive              | OFF                          |
  17514.      | innodb_log_buffer_size          | 1048576                      |
  17515.      | innodb_log_file_size            | 5242880                      |
  17516.      | innodb_log_files_in_group       | 2                            |
  17517.      | innodb_log_group_home_dir       | ./                           |
  17518.      | innodb_mirrored_log_groups      | 1                            |
  17519.      | innodb_thread_concurrency       | 8                            |
  17520.      | interactive_timeout             | 28800                        |
  17521.      | join_buffer_size                | 131072                       |
  17522.      | key_buffer_size                 | 16773120                     |
  17523.      | key_cache_age_threshold         | 300                          |
  17524.      | key_cache_block_size            | 1024                         |
  17525.      | key_cache_division_limit        | 100                          |
  17526.      | language                        | /usr/local/mysql/share/...   |
  17527.      | large_files_support             | ON                           |
  17528.      | local_infile                    | ON                           |
  17529.      | locked_in_memory                | OFF                          |
  17530.      | log                             | OFF                          |
  17531.      | log_bin                         | OFF                          |
  17532.      | log_slave_updates               | OFF                          |
  17533.      | log_slow_queries                | OFF                          |
  17534.      | log_update                      | OFF                          |
  17535.      | log_warnings                    | 1                            |
  17536.      | long_query_time                 | 10                           |
  17537.      | low_priority_updates            | OFF                          |
  17538.      | lower_case_table_names          | 0                            |
  17539.      | max_allowed_packet              | 1047552                      |
  17540.      | max_binlog_cache_size           | 4294967295                   |
  17541.      | max_binlog_size                 | 1073741824                   |
  17542.      | max_connect_errors              | 10                           |
  17543.      | max_connections                 | 100                          |
  17544.      | max_delayed_threads             | 20                           |
  17545.      | max_error_count                 | 64                           |
  17546.      | max_heap_table_size             | 16777216                     |
  17547.      | max_join_size                   | 4294967295                   |
  17548.      | max_relay_log_size              | 0                            |
  17549.      | max_sort_length                 | 1024                         |
  17550.      | max_tmp_tables                  | 32                           |
  17551.      | max_user_connections            | 0                            |
  17552.      | max_write_lock_count            | 4294967295                   |
  17553.      | myisam_max_extra_sort_file_size | 268435456                    |
  17554.      | myisam_max_sort_file_size       | 2147483647                   |
  17555.      | myisam_recover_options          | force                        |
  17556.      | myisam_repair_threads           | 1                            |
  17557.      | myisam_sort_buffer_size         | 8388608                      |
  17558.      | net_buffer_length               | 16384                        |
  17559.      | net_read_timeout                | 30                           |
  17560.      | net_retry_count                 | 10                           |
  17561.      | net_write_timeout               | 60                           |
  17562.      | open_files_limit                | 1024                         |
  17563.      | pid_file                        | /usr/local/mysql/name.pid    |
  17564.      | port                            | 3306                         |
  17565.      | protocol_version                | 10                           |
  17566.      | query_cache_limit               | 1048576                      |
  17567.      | query_cache_size                | 0                            |
  17568.      | query_cache_type                | ON                           |
  17569.      | read_buffer_size                | 131072                       |
  17570.      | read_rnd_buffer_size            | 262144                       |
  17571.      | rpl_recovery_rank               | 0                            |
  17572.      | server_id                       | 0                            |
  17573.      | skip_external_locking           | ON                           |
  17574.      | skip_networking                 | OFF                          |
  17575.      | skip_show_database              | OFF                          |
  17576.      | slave_net_timeout               | 3600                         |
  17577.      | slow_launch_time                | 2                            |
  17578.      | socket                          | /tmp/mysql.sock              |
  17579.      | sort_buffer_size                | 2097116                      |
  17580.      | sql_mode                        |                              |
  17581.      | table_cache                     | 64                           |
  17582.      | table_type                      | MYISAM                       |
  17583.      | thread_cache_size               | 3                            |
  17584.      | thread_stack                    | 131072                       |
  17585.      | timezone                        | EEST                         |
  17586.      | tmp_table_size                  | 33554432                     |
  17587.      | tmpdir                          | /tmp/:/mnt/hd2/tmp/          |
  17588.      | tx_isolation                    | READ-COMMITTED               |
  17589.      | version                         | 4.0.4-beta                   |
  17590.      | wait_timeout                    | 28800                        |
  17591.      +---------------------------------+------------------------------+
  17592.  
  17593. Most system variables are described here.  Variables with no version
  17594. indicated have been present since at least MySQL 3.22.  `InnoDB' system
  17595. variables are listed at *Note `InnoDB' start: InnoDB start.
  17596.  
  17597. Values for buffer sizes, lengths, and stack sizes are given in bytes
  17598. unless otherwise specified.
  17599.  
  17600. Information on tuning these variables can be found in *Note Server
  17601. parameters::.
  17602.  
  17603. `ansi_mode'
  17604.      This is `ON' if `mysqld' was started with `--ansi'.  *Note ANSI
  17605.      mode::.  This variable was added in MySQL 3.23.6 and removed in
  17606.      3.23.41.  See the description for `sql_mode'.
  17607.  
  17608. `back_log'
  17609.      The number of outstanding connection requests MySQL can have. This
  17610.      comes into play when the main MySQL thread gets very many
  17611.      connection requests in a very short time. It then takes some time
  17612.      (although very little) for the main thread to check the connection
  17613.      and start a new thread. The `back_log' value indicates how many
  17614.      requests can be stacked during this short time before MySQL
  17615.      momentarily stops answering new requests. You need to increase
  17616.      this only if you expect a large number of connections in a short
  17617.      period of time.
  17618.  
  17619.      In other words, this value is the size of the listen queue for
  17620.      incoming TCP/IP connections.  Your operating system has its own
  17621.      limit on the size of this queue.  The manual page for the Unix
  17622.      `listen()' system call should have more details.  Check your OS
  17623.      documentation for the maximum value for this variable.  Attempting
  17624.      to set `back_log' higher than your operating system limit will be
  17625.      ineffective.
  17626.  
  17627. `basedir'
  17628.      The MySQL installation base directory. This variable can be set
  17629.      with the `--basedir' option.
  17630.  
  17631. `bdb_cache_size'
  17632.      The size of the buffer that is allocated for caching indexes and
  17633.      rows for `BDB' tables.  If you don't use `BDB' tables, you should
  17634.      start `mysqld' with `--skip-bdb' to not waste memory for this
  17635.      cache.  This variable was added in MySQL 3.23.14.
  17636.  
  17637. `bdb_home'
  17638.      The base directory for `BDB' tables.  This should be assigned the
  17639.      same value as the `datadir' variable.  This variable was added in
  17640.      MySQL 3.23.14.
  17641.  
  17642. `bdb_log_buffer_size'
  17643.      The size of the buffer that is allocated for caching indexes and
  17644.      rows for `BDB' tables.  If you don't use `BDB' tables, you should
  17645.      set this to 0 or start `mysqld' with `--skip-bdb' to not waste
  17646.      memory for this cache.  This variable was added in MySQL 3.23.31.
  17647.  
  17648. `bdb_logdir'
  17649.      The directory where the `BDB' storage engine writes its log files.
  17650.      This variable can be set with the `--bdb-logdir' option.  This
  17651.      variable was added in MySQL 3.23.14.
  17652.  
  17653. `bdb_max_lock'
  17654.      The maximum number of locks you can have active on a `BDB' table
  17655.      (10,000 by default). You should increase this if errors such as the
  17656.      following occur when you perform long transactions or when
  17657.      `mysqld' has to examine many rows to calculate a query:
  17658.  
  17659.           bdb: Lock table is out of available locks
  17660.           Got error 12 from ...
  17661.  
  17662.      This variable was added in MySQL 3.23.29.
  17663.  
  17664. `bdb_shared_data'
  17665.      This is `ON' if you are using `--bdb-shared-data'.  This variable
  17666.      was added in MySQL 3.23.29.
  17667.  
  17668. `bdb_tmpdir'
  17669.      The value of the `--bdb-tmpdir' option.  This variable was added
  17670.      in MySQL 3.23.14.
  17671.  
  17672. `bdb_version'
  17673.      See the description for `version_bdb'.
  17674.  
  17675. `binlog_cache_size'
  17676.      The size of the cache to hold the SQL statements for the binary
  17677.      log during a transaction.  A binary log cache is allocated for
  17678.      each client if the server supports any transactional storage
  17679.      engines and, starting from MySQL 4.1.2, if the server has binary
  17680.      log enabled (`--log-bin' option). If you often use big,
  17681.      multiple-statement transactions, you can increase this to get more
  17682.      performance.  The `Binlog_cache_use' and `Binlog_cache_disk_use'
  17683.      status variables can be useful for tuning the size of this
  17684.      variable.  This variable was added in MySQL 3.23.29.  *Note Binary
  17685.      log::.
  17686.  
  17687. `bulk_insert_buffer_size'
  17688.      `MyISAM' uses a special tree-like cache to make bulk inserts
  17689.      faster for `INSERT ... SELECT', `INSERT ... VALUES (...), (...),
  17690.      ...', and `LOAD DATA INFILE'. This variable limits the size of the
  17691.      cache tree in bytes per thread. Setting it to 0 disables this
  17692.      optimization.  *Note*: This cache is used only when adding data to
  17693.      a non-empty table.  The default value is 8MB.  This variable was
  17694.      added in MySQL 4.0.3.  This variable previously was named
  17695.      `myisam_bulk_insert_tree_size'.
  17696.  
  17697. `character_set'
  17698.      The default character set.  This variable was added in MySQL
  17699.      3.23.3, then removed in MySQL 4.1.1 and replaced by the various
  17700.      `character_set_XXX' variables.
  17701.  
  17702. `character_set_client'
  17703.      The character set for statements that arrive from the client.
  17704.      This variable was added in MySQL 4.1.1.
  17705.  
  17706. `character_set_connection'
  17707.      The character set used for literals that do not have a character
  17708.      set introducer and for number-to-string conversion.  This variable
  17709.      was added in MySQL 4.1.1.
  17710.  
  17711. `character_set_database'
  17712.      The character set used by the default database.  The server sets
  17713.      this variable whenever the default database changes.  If there is
  17714.      no default database, the variable has the same value as
  17715.      `character_set_server'.  This variable was added in MySQL 4.1.1.
  17716.  
  17717. `character_set_results'
  17718.      The character set used for returning query results to the client.
  17719.      This variable was added in MySQL 4.1.1.
  17720.  
  17721. `character_set_server'
  17722.      The server default character set.  This variable was added in
  17723.      MySQL 4.1.1.
  17724.  
  17725. `character_set_system'
  17726.      The character set used by the server for storing identifiers.  The
  17727.      value is always `utf8'.  This variable was added in MySQL 4.1.1.
  17728.  
  17729. `character_sets'
  17730.      The supported character sets.  This variable was added in MySQL
  17731.      3.23.15 and removed in MySQL 4.1.1.  (Use `SHOW CHARACTER SET' for
  17732.      a list of character sets.)
  17733.  
  17734. `character_sets_dir'
  17735.      The directory where character sets are installed.  This variable
  17736.      was added in MySQL 4.1.2.
  17737.  
  17738. `collation_connection'
  17739.      The collation of the connection character set.  This variable was
  17740.      added in MySQL 4.1.1.
  17741.  
  17742. `collation_database'
  17743.      The collation used by the default database.  The server sets this
  17744.      variable whenever the default database changes.  If there is no
  17745.      default database, the variable has the same value as
  17746.      `collation_server'.  This variable was added in MySQL 4.1.1.
  17747.  
  17748. `collation_server'
  17749.      The server default collation.  This variable was added in MySQL
  17750.      4.1.1.
  17751.  
  17752. `concurrent_insert'
  17753.      If `ON' (the default), MySQL allows `INSERT' and `SELECT'
  17754.      statements to run concurrently for `MyISAM' tables that have no
  17755.      free blocks in the middle.  You can turn this option off by
  17756.      starting `mysqld' with `--safe' or `--skip-new'.  This variable
  17757.      was added in MySQL 3.23.7.
  17758.  
  17759. `connect_timeout'
  17760.      The number of seconds the `mysqld' server waits for a connect
  17761.      packet before responding with `Bad handshake'.
  17762.  
  17763. `datadir'
  17764.      The MySQL data directory. This variable can be set with the
  17765.      `--datadir' option.
  17766.  
  17767. `default_week_format'
  17768.      The default mode value to use for the `WEEK()' function.  This
  17769.      variable is available as of MySQL 4.0.14.
  17770.  
  17771. `delay_key_write'
  17772.      This option applies only to `MyISAM' tables. It can have one of the
  17773.      following values to affect handling of the `DELAY_KEY_WRITE' table
  17774.      option that can be used in `CREATE TABLE' statements.
  17775.  
  17776.      *Option**Description*
  17777.      `OFF'   `DELAYED_KEY_WRITE' is ignored.
  17778.      `ON'    MySQL honors the `DELAY_KEY_WRITE' option for
  17779.              `CREATE TABLE'. This is the default value.
  17780.      `ALL'   All new opened tables are treated as if they were
  17781.              created with the `DELAY_KEY_WRITE' option enabled.
  17782.  
  17783.      If `DELAY_KEY_WRITE' is enabled, this means that the key buffer for
  17784.      tables with this option are not flushed on every index update, but
  17785.      only when a table is closed.  This will speed up writes on keys a
  17786.      lot, but if you use this feature, you should add automatic
  17787.      checking of all `MyISAM' tables by starting the server with the
  17788.      `--myisam-recover' option (for example,
  17789.      `--myisam-recover=BACKUP,FORCE').  See *Note Server options:: and
  17790.      *Note MyISAM start::.
  17791.  
  17792.      Note that `--external-locking' doesn't offer any protection against
  17793.      index corruption for tables that use delayed key writes.
  17794.  
  17795.      This variable was added in MySQL 3.23.8.
  17796.  
  17797. `delayed_insert_limit'
  17798.      After inserting `delayed_insert_limit' delayed rows, the `INSERT
  17799.      DELAYED' handler thread checks whether there are any `SELECT'
  17800.      statements pending. If so, it allows them to execute before
  17801.      continuing to insert delayed rows.
  17802.  
  17803. `delayed_insert_timeout'
  17804.      How long an `INSERT DELAYED' handler thread should wait for
  17805.      `INSERT' statements before terminating.
  17806.  
  17807. `delayed_queue_size'
  17808.      This is a per-table limit on the number of rows to queue when
  17809.      handling `INSERT DELAYED' statements.  If the queue becomes full,
  17810.      any client that issues an `INSERT DELAYED' statement will wait
  17811.      until there is room in the queue again.
  17812.  
  17813. `expire_logs_days'
  17814.      The number of days for automatic binary log removal.  The default
  17815.      is 0, which means "no automatic removal."  This variable was added
  17816.      in MySQL 4.1.0.
  17817.  
  17818. `flush'
  17819.      This is `ON' if you have started `mysqld' with the `--flush'
  17820.      option.  This variable was added in MySQL 3.22.9.
  17821.  
  17822. `flush_time'
  17823.      If this is set to a non-zero value, all tables will be closed every
  17824.      `flush_time' seconds to free up resources and sync unflushed data
  17825.      to disk.  We recommend this option only on Windows 9x or Me, or on
  17826.      systems with minimal resources available.  This variable was added
  17827.      in MySQL 3.22.18.
  17828.  
  17829. `ft_boolean_syntax'
  17830.      The list of operators supported by boolean full-text searches
  17831.      performed using `IN BOOLEAN MODE'.  This variable was added in
  17832.      MySQL 4.0.1.  *Note Fulltext Boolean::.
  17833.  
  17834.      The default variable value is `'+ -><()~*:""&|''. The rules for
  17835.      changing the value are as follows:
  17836.  
  17837.         * Operator function is determined by position within the string.
  17838.  
  17839.         * The replacement value must be 14 characters.
  17840.  
  17841.         * Each character must be an ASCII non-alphanumeric character.
  17842.  
  17843.         * Either the first or second character must be a space.
  17844.  
  17845.         * No duplicates are allowed except the phrase quoting operators
  17846.           in positions 11 and 12. These two characters are not required
  17847.           to be the same, but they are the only two that may be.
  17848.  
  17849.         * Positions 10, 13, and 14 (which by default are set to `:',
  17850.           `&', and `|') are reserved for future extensions.
  17851.  
  17852.  
  17853. `ft_max_word_len'
  17854.      The maximum length of the word to be included in a `FULLTEXT'
  17855.      index.  This variable was added in MySQL 4.0.0.
  17856.  
  17857.      *Note*: `FULLTEXT' indexes must be rebuilt after changing this
  17858.      variable.  Use `REPAIR TABLE TBL_NAME QUICK'.
  17859.  
  17860. `ft_min_word_len'
  17861.      The minimum length of the word to be included in a `FULLTEXT'
  17862.      index.  This variable was added in MySQL 4.0.0.
  17863.  
  17864.      *Note*: `FULLTEXT' indexes must be rebuilt after changing this
  17865.      variable.  Use `REPAIR TABLE TBL_NAME QUICK'.
  17866.  
  17867. `ft_query_expansion_limit'
  17868.      The number of top matches to use for full-text searches performed
  17869.      using `WITH QUERY EXPANSION'.  This variable was added in MySQL
  17870.      4.1.1.
  17871.  
  17872. `ft_stopword_file'
  17873.      The file from which to read the list of stopwords for full-text
  17874.      searches.  All the words from the file are used; comments are
  17875.      _not_ honored.  By default, a built-in list of stopwords is used
  17876.      (as defined in the `myisam/ft_static.c' file).  Setting this
  17877.      variable to the empty string (`''') disables stopword filtering.
  17878.      This variable was added in MySQL 4.0.10.
  17879.  
  17880.      *Note*: `FULLTEXT' indexes must be rebuilt after changing this
  17881.      variable.  Use `REPAIR TABLE TBL_NAME QUICK'.
  17882.  
  17883. `group_concat_max_len'
  17884.      The maximum allowed result length for the `GROUP_CONCAT()'
  17885.      function.  This variable was added in MySQL 4.1.0.
  17886.  
  17887. `have_archive'
  17888.      `YES' if `mysqld' supports `ARCHIVE' tables.  This variable was
  17889.      added in MySQL 4.1.3.
  17890.  
  17891. `have_bdb'
  17892.      `YES' if `mysqld' supports `BDB' tables. `DISABLED' if
  17893.      `--skip-bdb' is used.  This variable was added in MySQL 3.23.30.
  17894.  
  17895. `have_compress'
  17896.      Whether the `zlib' compression library is available to the server.
  17897.      If not, the `COMPRESS()' and `UNCOMPRESS()' functions cannot be
  17898.      used.  This variable was added in MySQL 4.1.1.
  17899.  
  17900. `have_crypt'
  17901.      Whether the `crypt()' system call is available to the server.  If
  17902.      not, the `CRYPT()' function cannot be used.  This variable was
  17903.      added in MySQL 4.0.10.
  17904.  
  17905. `have_geometry'
  17906.      Whether the server supports spatial data types.  This variable was
  17907.      added in MySQL 4.1.3.
  17908.  
  17909. `have_innodb'
  17910.      `YES' if `mysqld' supports `InnoDB' tables. `DISABLED' if
  17911.      `--skip-innodb' is used.  This variable was added in MySQL 3.23.37.
  17912.  
  17913. `have_isam'
  17914.      `YES' if `mysqld' supports `ISAM' tables. `DISABLED' if
  17915.      `--skip-isam' is used.  This variable was added in MySQL 3.23.30.
  17916.  
  17917. `have_ndbcluster'
  17918.      `YES' if `mysqld' supports `NDBCLUSTER' tables.  `DISABLED' if
  17919.      `--skip-ndbcluster' is used.  This variable was added in MySQL
  17920.      4.1.2.
  17921.  
  17922. `have_openssl'
  17923.      `YES' if `mysqld' supports SSL (encryption) of the client/server
  17924.      protocol.  This variable was added in MySQL 3.23.43.
  17925.  
  17926. `have_query_cache'
  17927.      `YES' if `mysqld' supports the query cache.  This variable was
  17928.      added in MySQL 4.0.2.
  17929.  
  17930. `have_raid'
  17931.      `YES' if `mysqld' supports the `RAID' option.  This variable was
  17932.      added in MySQL 3.23.30.
  17933.  
  17934. `have_rtree_keys'
  17935.      Whether `RTREE' indexes are available. (These are used for spatial
  17936.      indexed in `MyISAM' tables.)  This variable was added in MySQL
  17937.      4.1.3.
  17938.  
  17939. `have_symlink'
  17940.      Whether symbolic link support is enabled. This is required on Unix
  17941.      for support of the `DATA DIRECTORY' and `INDEX DIRECTORY' table
  17942.      options.  This variable was added in MySQL 4.0.0.
  17943.  
  17944. `init_connect'
  17945.      A string to be executed by the server for each client that
  17946.      connects.  The string consists of one or more SQL statements. To
  17947.      specify multiple statements, separate them by semicolon characters.
  17948.      For example, each client begins by default with autocommit mode
  17949.      enabled.  There is no global server variable to specify that
  17950.      autocommit should be disabled by default, but `init_connect' can
  17951.      be used to achieve the same effect:
  17952.  
  17953.           SET GLOBAL init_connect='SET AUTOCOMMIT=0';
  17954.  
  17955.      This variable can also be set on the command line or in an option
  17956.      file.  To set the variable as just shown using an option file,
  17957.      include these lines:
  17958.  
  17959.           [mysqld]
  17960.           init_connect='SET AUTOCOMMIT=0'
  17961.  
  17962.      This variable was added in MySQL 4.1.2.
  17963.  
  17964. `init_file'
  17965.      The name of the file specified with the `--init-file' option when
  17966.      you start the server.  This is a file containing SQL statements
  17967.      that you want the server to execute when it starts.  Each
  17968.      statement must be on a single line and should not include comments.
  17969.      This variable was added in MySQL 3.23.2.
  17970.  
  17971. `init_slave'
  17972.      This variable is similar to `init_connect', but is a string to be
  17973.      executed by a slave server each time the SQL thread starts.  The
  17974.      format of the string is the same as for the `init_connect'
  17975.      variable.  This variable was added in MySQL 4.1.2.
  17976.  
  17977. `innodb_XXX'
  17978.      The `InnoDB' system variables are listed at *Note `InnoDB' start:
  17979.      InnoDB start.
  17980.  
  17981. `interactive_timeout'
  17982.      The number of seconds the server waits for activity on an
  17983.      interactive connection before closing it.  An interactive client
  17984.      is defined as a client that uses the `CLIENT_INTERACTIVE' option to
  17985.      `mysql_real_connect()'.  See also `wait_timeout'.
  17986.  
  17987. `join_buffer_size'
  17988.      The size of the buffer that is used for full joins (joins that do
  17989.      not use indexes).  Normally the best way to get fast joins is to
  17990.      add indexes.  Increase the value of `join_buffer_size' to get a
  17991.      faster full join when adding indexes is not possible.  One join
  17992.      buffer is allocated for each full join between two tables. For a
  17993.      complex join between several tables for which indexes are not
  17994.      used, multiple join buffers might be necessary.
  17995.  
  17996. `key_buffer_size'
  17997.      Index blocks for `MyISAM' and `ISAM' tables are buffered and are
  17998.      shared by all threads.  `key_buffer_size' is the size of the buffer
  17999.      used for index blocks.  The key buffer is also known as the key
  18000.      cache.
  18001.  
  18002.      Increase the value to get better index handling (for all reads and
  18003.      multiple writes) to as much as you can afford. Using a value that
  18004.      is 25% of total memory on a machine that mainly runs MySQL is
  18005.      quite common.  However, if you make the value too large (for
  18006.      example, more than 50% of your total memory) your system might
  18007.      start to page and become extremely slow.  MySQL relies on the
  18008.      operating system to perform filesystem caching for data reads, so
  18009.      you must leave some room for the filesystem cache.
  18010.  
  18011.      For even more speed when writing many rows at the same time, use
  18012.      `LOCK TABLES'.  *Note `LOCK TABLES': LOCK TABLES.
  18013.  
  18014.      You can check the performance of the key buffer by issuing a `SHOW
  18015.      STATUS' statement and examining the `Key_read_requests',
  18016.      `Key_reads', `Key_write_requests', and `Key_writes' status
  18017.      variables.  *Note `SHOW': SHOW.
  18018.  
  18019.      The `Key_reads/Key_read_requests' ratio should normally be less
  18020.      than 0.01.  The `Key_writes/Key_write_requests' ratio is usually
  18021.      near 1 if you are using mostly updates and deletes, but might be
  18022.      much smaller if you tend to do updates that affect many rows at
  18023.      the same time or if you are using the `DELAY_KEY_WRITE' table
  18024.      option.
  18025.  
  18026.      The fraction of the key buffer in use can be determined using
  18027.      `key_buffer_size' in conjunction with the `Key_blocks_used' status
  18028.      variable and the buffer block size.  From MySQL 4.1.1 on, the
  18029.      buffer block size is available from the `key_cache_block_size'
  18030.      server variable. The fraction of the buffer in use is:
  18031.  
  18032.           (Key_blocks_used * key_cache_block_size) / key_buffer_size
  18033.  
  18034.      Before MySQL 4.1.1, key cache blocks are 1024 bytes, so the
  18035.      fraction of the key buffer in use is:
  18036.  
  18037.           (Key_blocks_used * 1024) / key_buffer_size
  18038.  
  18039.      *Note `MyISAM' key cache: MyISAM key cache.
  18040.  
  18041. `key_cache_age_threshold'
  18042.      This value controls the demotion of buffers from the hot sub-chain
  18043.      of a key cache to the warm sub-chain.  Lower values cause demotion
  18044.      to happen more quickly.  The minimum value is 100.  The default
  18045.      value is 300.  This variable was added in MySQL 4.1.1.  *Note
  18046.      `MyISAM' key cache: MyISAM key cache.
  18047.  
  18048. `key_cache_block_size'
  18049.      The size in bytes of blocks in the key cache.  The default value
  18050.      is 1024.  This variable was added in MySQL 4.1.1.  *Note `MyISAM'
  18051.      key cache: MyISAM key cache.
  18052.  
  18053. `key_cache_division_limit'
  18054.      The division point between the hot and warm sub-chains of the key
  18055.      cache buffer chain. The value is the percentage of the buffer
  18056.      chain to use for the warm sub-chain.  Allowable values range from
  18057.      1 to 100.  The default value is 100.  This variable was added in
  18058.      MySQL 4.1.1.  *Note `MyISAM' key cache: MyISAM key cache.
  18059.  
  18060. `language'
  18061.      The language used for error messages.
  18062.  
  18063. `large_file_support'
  18064.      Whether `mysqld' was compiled with options for large file support.
  18065.      This variable was added in MySQL 3.23.28.
  18066.  
  18067. `license'
  18068.      The type of license the server has.  This variable was added in
  18069.      MySQL 4.0.19.
  18070.  
  18071. `local_infile'
  18072.      Whether `LOCAL' is supported for `LOAD DATA INFILE' statements.
  18073.      This variable was added in MySQL 4.0.3.
  18074.  
  18075. `locked_in_memory'
  18076.      Whether `mysqld' was locked in memory with `--memlock'.  This
  18077.      variable was added in MySQL 3.23.25.
  18078.  
  18079. `log'
  18080.      Whether logging of all queries to the general query log is enabled.
  18081.      *Note Query log::.
  18082.  
  18083. `log_bin'
  18084.      Whether the binary log is enabled.  This variable was added in
  18085.      MySQL 3.23.14.  *Note Binary log::.
  18086.  
  18087. `log_error'
  18088.      The location of the error log.  This variable was added in MySQL
  18089.      4.0.10.
  18090.  
  18091. `log_slave_updates'
  18092.      Whether updates received by a slave server from a master server
  18093.      should be logged to the slave's own binary log. Binary logging
  18094.      must be enabled on the slave for this to have any effect.  This
  18095.      variable was added in MySQL 3.23.17.  *Note Replication Options::.
  18096.  
  18097. `log_slow_queries'
  18098.      Whether slow queries should be logged.  "Slow" is determined by
  18099.      the value of the `long_query_time' variable.  This variable was
  18100.      added in MySQL 4.0.2.  *Note Slow query log::.
  18101.  
  18102. `log_update'
  18103.      Whether the update log is enabled.  This variable was added in
  18104.      MySQL 3.22.18.  Note that the binary log is preferable to the
  18105.      update log, which is unavailable as of MySQL 5.0.  *Note Update
  18106.      log::.
  18107.  
  18108. `log_warnings'
  18109.      Whether to produce additional warning messages.  This variable was
  18110.      added in MySQL 4.0.3.  It is enabled by default as of MySQL 4.0.19
  18111.      and 4.1.2.  As of MySQL 4.0.21 and 4.1.3, aborted connections are
  18112.      not logged to the error log unless the value is greater than 1.
  18113.  
  18114. `long_query_time'
  18115.      If a query takes longer than this many seconds, the `Slow_queries'
  18116.      status variable is incremented. If you are using the
  18117.      `--log-slow-queries' option, the query is logged to the slow query
  18118.      log file. This value is measured in real time, not CPU time, so a
  18119.      query that is under the threshold on a lightly loaded system might
  18120.      be above the threshold on a heavily loaded one.  *Note Slow query
  18121.      log::.
  18122.  
  18123. `low_priority_updates'
  18124.      If set to `1', all `INSERT', `UPDATE', `DELETE', and `LOCK TABLE
  18125.      WRITE' statements wait until there is no pending `SELECT' or `LOCK
  18126.      TABLE READ' on the affected table.  This variable previously was
  18127.      named `sql_low_priority_updates'.  It was added in MySQL 3.22.5.
  18128.  
  18129. `lower_case_file_system'
  18130.      This variable indicates whether the filesystem where the data
  18131.      directory is located has case insensitive filenames.  `ON' means
  18132.      filenames are case insensitive, `OFF' means they are case
  18133.      sensitive.  This variable was added in MySQL 4.0.19.
  18134.  
  18135. `lower_case_table_names'
  18136.      If set to 1, table names are stored in lowercase on disk and table
  18137.      name comparisons are not case sensitive.  This variable was added
  18138.      in MySQL 3.23.6.  If set to 2 (new in 4.0.18), table names are
  18139.      stored as given but compared in lowercase.  From MySQL 4.0.2, this
  18140.      option also applies to database names.  From 4.1.1, it also
  18141.      applies to table aliases.  *Note Name case sensitivity::.
  18142.  
  18143.      You should _not_ set this variable to 0 if you are running MySQL
  18144.      on a system that does not have case-sensitive filenames (such as
  18145.      Windows or Mac OS X).  New in 4.0.18:  If this variable is not set
  18146.      at startup and the filesystem on which the data directory is
  18147.      located does not have case-sensitive filenames, MySQL
  18148.      automatically sets `lower_case_table_names' to 2.
  18149.  
  18150. `max_allowed_packet'
  18151.      The maximum size of one packet or any generated/intermediate
  18152.      string.
  18153.  
  18154.      The packet message buffer is initialized to `net_buffer_length'
  18155.      bytes, but can grow up to `max_allowed_packet' bytes when needed.
  18156.      This value by default is small, to catch big (possibly wrong)
  18157.      packets.
  18158.  
  18159.      You must increase this value if you are using big `BLOB' columns or
  18160.      long strings. It should be as big as the biggest `BLOB' you want to
  18161.      use.  The protocol limit for `max_allowed_packet' is 16MB before
  18162.      MySQL 4.0 and 1GB thereafter.
  18163.  
  18164. `max_binlog_cache_size'
  18165.      If a multiple-statement transaction requires more than this amount
  18166.      of memory, you will get the error `Multi-statement transaction
  18167.      required more than 'max_binlog_cache_size' bytes of storage'.
  18168.      This variable was added in MySQL 3.23.29.
  18169.  
  18170. `max_binlog_size'
  18171.      If a write to the binary log exceeds the given value, rotate the
  18172.      binary logs.  You cannot set this variable to more than 1GB or to
  18173.      less than 4096 bytes.  (The minimum before MYSQL 4.0.14 is 1024
  18174.      bytes.) The default value is 1GB.  This variable was added in
  18175.      MySQL 3.23.33.
  18176.  
  18177.      Note if you are using transactions: A transaction is written in
  18178.      one chunk to the binary log, hence it is never split between
  18179.      several binary logs.  Therefore, if you have big transactions, you
  18180.      might see binary logs bigger than `max_binlog_size'.
  18181.  
  18182.      If `max_relay_log_size' is 0, the value of `max_binlog_size'
  18183.      applies to relay logs as well. `max_relay_log_size' was added in
  18184.      MySQL 4.0.14.
  18185.  
  18186. `max_connect_errors'
  18187.      If there are more than this number of interrupted connections from
  18188.      a host, that host is blocked from further connections.  You can
  18189.      unblock blocked hosts with the `FLUSH HOSTS' statement.
  18190.  
  18191. `max_connections'
  18192.      The number of simultaneous client connections allowed. Increasing
  18193.      this value increases the number of file descriptors that `mysqld'
  18194.      requires.  See *Note Table cache:: for comments on file descriptor
  18195.      limits.  Also see *Note Too many connections::.
  18196.  
  18197. `max_delayed_threads'
  18198.      Don't start more than this number of threads to handle `INSERT
  18199.      DELAYED' statements.  If you try to insert data into a new table
  18200.      after all `INSERT DELAYED' threads are in use, the row will be
  18201.      inserted as if the `DELAYED' attribute wasn't specified. If you
  18202.      set this to 0, MySQL never creates a thread to handle `DELAYED'
  18203.      rows; in effect, this disables `DELAYED' entirely.  This variable
  18204.      was added in MySQL 3.23.0.
  18205.  
  18206. `max_error_count'
  18207.      The maximum number of error, warning, and note messages to be
  18208.      stored for display by `SHOW ERRORS' or `SHOW WARNINGS'.  This
  18209.      variable was added in MySQL 4.1.0.
  18210.  
  18211. `max_heap_table_size'
  18212.      This variable sets the maximum size to which `MEMORY' (`HEAP')
  18213.      tables are allowed to grow.  The value of the variable is used to
  18214.      calculate `MEMORY' table `MAX_ROWS' values.  Setting this variable
  18215.      has no effect on any existing `MEMORY' table, unless the table is
  18216.      re-created with a statement such as `CREATE TABLE' or `TRUNCATE
  18217.      TABLE', or altered with `ALTER TABLE'.  This variable was added in
  18218.      MySQL 3.23.0.
  18219.  
  18220. `max_insert_delayed_threads'
  18221.      This variable is a synonym for `max_delayed_threads'.  It was
  18222.      added in MySQL 4.0.19.
  18223.  
  18224. `max_join_size'
  18225.      Don't allow `SELECT' statements that probably will need to examine
  18226.      more than `max_join_size' row combinations or are likely to do more
  18227.      than `max_join_size' disk seeks.  By setting this value, you can
  18228.      catch `SELECT' statements where keys are not used properly and
  18229.      that would probably take a long time.  Set it if your users tend
  18230.      to perform joins that lack a `WHERE' clause, that take a long
  18231.      time, or that return millions of rows.
  18232.  
  18233.      Setting this variable to a value other than `DEFAULT' resets the
  18234.      `SQL_BIG_SELECTS' value to `0'.  If you set the `SQL_BIG_SELECTS'
  18235.      value again, the `max_join_size' variable is ignored.
  18236.  
  18237.      If a query result already is in the query cache, no result size
  18238.      check is performed, because the result has already been computed
  18239.      and it does not burden the server to send it to the client.
  18240.  
  18241.      This variable previously was named `sql_max_join_size'.
  18242.  
  18243. `max_length_for_sort_data'
  18244.      The cutoff on the size of index values that determines which
  18245.      `filesort' algorithm to use.  *Note `ORDER BY' optimization: ORDER
  18246.      BY optimization.  This variable was added in MySQL 4.1.1
  18247.  
  18248. `max_relay_log_size'
  18249.      If a write by a replication slave to its relay log exceeds the
  18250.      given value, rotate the relay log.  This variable enables you to
  18251.      put different size constraints on relay logs and binary logs.
  18252.      However, setting the variable to 0 makes MySQL use
  18253.      `max_binlog_size' for both binary logs and relay logs.  You must
  18254.      set `max_relay_log_size' to between 4096 bytes and 1GB
  18255.      (inclusive), or to 0. The default value is 0.  This variable was
  18256.      added in MySQL 4.0.14.  *Note Replication Implementation Details::.
  18257.  
  18258. `max_seeks_for_key'
  18259.      Limit the assumed maximum number of seeks when looking up rows
  18260.      based on a key.  The MySQL optimizer will assume that no more than
  18261.      this number of key seeks will be required when searching for
  18262.      matching rows in a table by scanning a key, regardless of the
  18263.      actual cardinality of the key (*note SHOW INDEX::). By setting
  18264.      this to a low value (100?), you can force MySQL to prefer keys
  18265.      instead of table scans.
  18266.  
  18267.      This variable was added in MySQL 4.0.14.
  18268.  
  18269. `max_sort_length'
  18270.      The number of bytes to use when sorting `BLOB' or `TEXT' values.
  18271.      Only the first `max_sort_length' bytes of each value are used; the
  18272.      rest are ignored.
  18273.  
  18274. `max_tmp_tables'
  18275.      The maximum number of temporary tables a client can keep open at
  18276.      the same time.  (This option doesn't yet do anything.)
  18277.  
  18278. `max_user_connections'
  18279.      The maximum number of simultaneous connections allowed to any
  18280.      given MySQL account.  A value of 0 means "no limit."  This
  18281.      variable was added in MySQL 3.23.34.
  18282.  
  18283. `max_write_lock_count'
  18284.      After this many write locks, allow some read locks to run in
  18285.      between.  This variable was added in MySQL 3.23.7.
  18286.  
  18287. `myisam_data_pointer_size'
  18288.      Default pointer size in bytes to be used by `CREATE TABLE' for
  18289.      `MyISAM' tables when no `MAX_ROWS' option is specified.  This
  18290.      variable cannot be less than 2 or larger than 8.  The default
  18291.      value is 4.  This variable was added in MySQL 4.1.2.  *Note
  18292.      `myisam_data_pointer_size': Full table.
  18293.  
  18294. `myisam_max_extra_sort_file_size'
  18295.      If the temporary file used for fast `MyISAM' index creation would
  18296.      be larger than using the key cache by the amount specified here,
  18297.      prefer the key cache method.  This is mainly used to force long
  18298.      character keys in large tables to use the slower key cache method
  18299.      to create the index.  This variable was added in MySQL 3.23.37.
  18300.      *Note*: The value is given in megabytes before 4.0.3 and in bytes
  18301.      thereafter.
  18302.  
  18303. `myisam_max_sort_file_size'
  18304.      The maximum size of the temporary file MySQL is allowed to use
  18305.      while re-creating a `MyISAM' index (during `REPAIR TABLE', `ALTER
  18306.      TABLE', or `LOAD DATA INFILE').  If the file size would be bigger
  18307.      than this value, the index will be created using the key cache
  18308.      instead, which is slower.  This variable was added in MySQL
  18309.      3.23.37.  *Note*: The value is given in megabytes before 4.0.3 and
  18310.      in bytes thereafter.
  18311.  
  18312. `myisam_recover_options'
  18313.      The value of the `--myisam-recover' option.  This variable was
  18314.      added in MySQL 3.23.36.
  18315.  
  18316. `myisam_repair_threads'
  18317.      If this value is greater than 1, `MyISAM' table indexes are
  18318.      created in parallel (each index in its own thread) during the
  18319.      `Repair by sorting' process.  The default value is 1.  *Note*:
  18320.      Multi-threaded repair is still _alpha_ quality code.  This
  18321.      variable was added in MySQL 4.0.13.
  18322.  
  18323. `myisam_sort_buffer_size'
  18324.      The buffer that is allocated when sorting `MyISAM' indexes during a
  18325.      `REPAIR TABLE' or when creating indexes with `CREATE INDEX' or
  18326.      `ALTER TABLE'.  This variable was added in MySQL 3.23.16.
  18327.  
  18328. `named_pipe'
  18329.      On Windows, indicates whether the server supports connections over
  18330.      named pipes.  This variable was added in MySQL 3.23.50.
  18331.  
  18332. `net_buffer_length'
  18333.      The communication buffer is reset to this size between queries.
  18334.      This should not normally be changed, but if you have very little
  18335.      memory, you can set it to the expected length of SQL statements
  18336.      sent by clients.  If statements exceed this length, the buffer is
  18337.      automatically enlarged, up to `max_allowed_packet' bytes.
  18338.  
  18339. `net_read_timeout'
  18340.      The number of seconds to wait for more data from a connection
  18341.      before aborting the read.  When the server is reading from the
  18342.      client, `net_read_timeout' is the timeout value controlling when
  18343.      to abort.  When the server is writing to the client,
  18344.      `net_write_timeout' is the timeout value controlling when to abort.
  18345.      See also `slave_net_timeout'.  This variable was added in MySQL
  18346.      3.23.20.
  18347.  
  18348. `net_retry_count'
  18349.      If a read on a communication port is interrupted, retry this many
  18350.      times before giving up.  This value should be set quite high on
  18351.      FreeBSD because internal interrupts are sent to all threads.  This
  18352.      variable was added in MySQL 3.23.7.
  18353.  
  18354. `net_write_timeout'
  18355.      The number of seconds to wait for a block to be written to a
  18356.      connection before aborting the write.  See also `net_read_timeout'.
  18357.      This variable was added in MySQL 3.23.20.
  18358.  
  18359. `new'
  18360.      This variable is used in MySQL 4.0 to turn on some 4.1 behaviors.
  18361.      This variable was added in MySQL 4.0.12.
  18362.  
  18363. `old_passwords'
  18364.      Whether the server should use pre-4.1-style passwords for MySQL
  18365.      user accounts.  This variable was added in MySQL 4.1.1.
  18366.  
  18367. `open_files_limit'
  18368.      The number of files that the operating system allows `mysqld' to
  18369.      open.  This is the real value allowed by the system and might be
  18370.      different from the value you gave `mysqld' as a startup option.
  18371.      The value is 0 on systems where MySQL can't change the number of
  18372.      open files.  This variable was added in MySQL 3.23.20.
  18373.  
  18374. `optimizer_prune_level'
  18375.      Controls the heuristics applied during query optimization to prune
  18376.      less-promising partial plans from the optimizer search space. A
  18377.      value of 0 disables heuristics so that the optimizer performs an
  18378.      exhaustive search. A value of 1 causes the optimizer to prune
  18379.      plans based on the number of rows retrieved by intermediate plans.
  18380.      This variable was added in MySQL 5.0.1.
  18381.  
  18382. `optimizer_search_depth'
  18383.      The maximum depth of search performed by the query optimizer.
  18384.      Values larger than the number of relations in a query result in
  18385.      better query plans, but take longer to generate an execution plan
  18386.      for a query. Values smaller than the number of relations in a
  18387.      query return an execution plan quicker, but the resulting plan may
  18388.      be far from being optimal. If set to 0, the system automatically
  18389.      picks a reasonable value. If set to the maximum number of tables
  18390.      used in a query plus 2, the optimizer switches to the original
  18391.      algorithm used before MySQL 5.0.1 that performs an exhaustive
  18392.      search.  This variable was added in MySQL 5.0.1.
  18393.  
  18394. `pid_file'
  18395.      The pathname of the process ID (PID) file. This variable can be set
  18396.      with the `--pid-file' option.  This variable was added in MySQL
  18397.      3.23.23.
  18398.  
  18399. `port'
  18400.      The port on which the server listens for TCP/IP connections.  This
  18401.      variable can be set with the `--port' option.
  18402.  
  18403. `preload_buffer_size'
  18404.      The size of the buffer that is allocated when preloading indexes.
  18405.      This variable was added in MySQL 4.1.1.
  18406.  
  18407. `protocol_version'
  18408.      The version of the client/server protocol used by the MySQL server.
  18409.      This variable was added in MySQL 3.23.18.
  18410.  
  18411. `query_alloc_block_size'
  18412.      The allocation size of memory blocks that are allocated for
  18413.      objects created during query parsing and execution. If you have
  18414.      problems with memory fragmentation, it might help to increase this
  18415.      a bit.  This variable was added in MySQL 4.0.16.
  18416.  
  18417. `query_cache_limit'
  18418.      Don't cache results that are bigger than this. The default value
  18419.      is 1MB.  This variable was added in MySQL 4.0.1.
  18420.  
  18421. `query_cache_min_res_unit'
  18422.      The minimum size for blocks allocated by the query cache.  The
  18423.      default value is 4KB. Tuning information for this variable is
  18424.      given in *Note Query Cache Configuration::.  This variable is
  18425.      present from MySQL 4.1.
  18426.  
  18427. `query_cache_size'
  18428.      The amount of memory allocated for caching query results.  The
  18429.      default value is 0, which disables the query cache.  Note that
  18430.      this amount of memory will be allocated even if `query_cache_type'
  18431.      is set to 0.  This variable was added in MySQL 4.0.1.
  18432.  
  18433. `query_cache_type'
  18434.      Set query cache type. Setting the `GLOBAL' value sets the type for
  18435.      all clients that connect thereafter. Individual clients can set the
  18436.      `SESSION' value to affect their own use of the query cache.
  18437.  
  18438.      *Option*   *Description*
  18439.      `0' or     Don't cache or retrieve results.  Note that
  18440.      `OFF'      this will not deallocate the query cache
  18441.                 buffer. To do that, you should set
  18442.                 `query_cache_size' to 0.
  18443.      `1' or     Cache all query results except for those that
  18444.      `ON'       begin with `SELECT SQL_NO_CACHE'.
  18445.      `2' or     Cache results only for queries that begin with
  18446.      `DEMAND'   `SELECT SQL_CACHE'.
  18447.  
  18448.      This variable was added in MySQL 4.0.3.
  18449.  
  18450. `query_cache_wlock_invalidate'
  18451.      Normally, when one client acquires a `WRITE' lock on a `MyISAM'
  18452.      table, other clients are not blocked from issuing queries for the
  18453.      table if the query results are present in the query cache. Setting
  18454.      this variable to 1 causes acquisition of a `WRITE' lock for a
  18455.      table to invalidate any queries in the query cache that refer to
  18456.      the table. This forces other clients that attempt to access the
  18457.      table to wait while the lock is in effect.  This variable was
  18458.      added in MySQL 4.0.19.
  18459.  
  18460. `query_prealloc_size'
  18461.      The size of the persistent buffer used for query parsing and
  18462.      execution.  This buffer is not freed between queries.  If you are
  18463.      running complex queries, a larger `query_prealloc_size' value
  18464.      might be helpful in improving performance, because it can reduce
  18465.      the need for the server to perform memory allocation during query
  18466.      execution operations.  This variable was added in MySQL 4.0.16.
  18467.  
  18468. `range_alloc_block_size'
  18469.      The size of blocks that are allocated when doing range
  18470.      optimization.  This variable was added in MySQL 4.0.16.
  18471.  
  18472. `read_buffer_size'
  18473.      Each thread that does a sequential scan allocates a buffer of this
  18474.      size for each table it scans. If you do many sequential scans, you
  18475.      might want to increase this value.  This variable was added in
  18476.      MySQL 4.0.3.  Previously, it was named `record_buffer'.
  18477.  
  18478. `read_only'
  18479.      When the variable is set to `ON' for a replication slave server, it
  18480.      causes the slave to allow no updates except from slave threads or
  18481.      from users with the `SUPER' privilege.  This can be useful to
  18482.      ensure that a slave server accepts no updates from clients.  This
  18483.      variable was added in MySQL 4.0.14.
  18484.  
  18485. `relay_log_purge'
  18486.      Disables or enables automatic purging of relay logs as soon as
  18487.      they are not needed any more.  The default value is 1 (enabled).
  18488.      This variable was added in MySQL 4.1.1.
  18489.  
  18490. `read_rnd_buffer_size'
  18491.      When reading rows in sorted order after a sort, the rows are read
  18492.      through this buffer to avoid disk seeks.  Setting the variable to
  18493.      a large value can improve `ORDER BY' performance by a lot.
  18494.      However, this is a buffer allocated for each client, so you should
  18495.      not set the global variable to a large value. Instead, change the
  18496.      session variable only from within those clients that need to run
  18497.      large queries.  This variable was added in MySQL 4.0.3.
  18498.      Previously, it was named `record_rnd_buffer'.
  18499.  
  18500. `safe_show_database'
  18501.      Don't show databases for which the user has no database or table
  18502.      privileges. This can improve security if you're concerned about
  18503.      people being able to see what databases other users have. See also
  18504.      `skip_show_database'.
  18505.  
  18506.      This variable was removed in MySQL 4.0.5. Instead, use the `SHOW
  18507.      DATABASES' privilege to control access by MySQL accounts to
  18508.      database names.
  18509.  
  18510. `secure_auth'
  18511.      If the MySQL server has been started with the `--secure-auth'
  18512.      option, it blocks connections from all accounts that have
  18513.      passwords stored in the old (pre-4.1) format. In that case, the
  18514.      value of this variable is `ON', otherwise it is `OFF'.
  18515.  
  18516.      You should enable this option if you want to prevent all usage of
  18517.      passwords in old format (and hence insecure communication over the
  18518.      network).  This variable was added in MySQL 4.1.1.
  18519.  
  18520.      Server startup will fail with an error if this option is enabled
  18521.      and the privilege tables are in pre-4.1 format.
  18522.  
  18523.      When used as a client-side option, the client refuses to connect
  18524.      to a server if the server requires a password in old format for
  18525.      the client account.
  18526.  
  18527. `server_id'
  18528.      The value of the `--server-id' option. It is used for master and
  18529.      slave replication servers.  This variable was added in MySQL
  18530.      3.23.26.
  18531.  
  18532. `shared_memory'
  18533.      Whether or not the server allows shared-memory connections.
  18534.      Currently, only Windows servers support this.  This variable was
  18535.      added in MySQL 4.1.1.
  18536.  
  18537. `shared_memory_base_name'
  18538.      Whether or not the server allows shared-memory connections.
  18539.      Currently, only Windows servers support this.  This variable was
  18540.      added in MySQL 4.1.0.
  18541.  
  18542. `skip_external_locking'
  18543.      This is `OFF' if `mysqld' uses external locking.  This variable
  18544.      was added in MySQL 4.0.3.  Previously, it was named `skip_locking'.
  18545.  
  18546. `skip_networking'
  18547.      This is `ON' if the server allows only local (non-TCP/IP)
  18548.      connections.  On Unix, local connections use a Unix socket file.
  18549.      On Windows, local connections use a named pipe.  On NetWare, only
  18550.      TCP/IP connections are supported, so do not set this variable to
  18551.      `ON'.  This variable was added in MySQL 3.22.23.
  18552.  
  18553. `skip_show_database'
  18554.      This prevents people from using the `SHOW DATABASES' statement if
  18555.      they don't have the `SHOW DATABASES' privilege. This can improve
  18556.      security if you're concerned about people being able to see what
  18557.      databases other users have. See also `safe_show_database'.  This
  18558.      variable was added in MySQL 3.23.4.  As of MySQL 4.0.2, its effect
  18559.      also depends on the `SHOW DATABASES' privilege: If the variable
  18560.      value is `ON', the `SHOW DATABASES' statement is allowed only to
  18561.      users who have the `SHOW DATABASES' privilege, and the statement
  18562.      displays all database names.  If the value is `OFF', `SHOW
  18563.      DATABASES' is allowed to all users, but displays each database
  18564.      name only if the user has the `SHOW DATABASES' privilege or some
  18565.      privilege for the database.
  18566.  
  18567. `slave_compressed_protocol'
  18568.      Whether to use compression of the slave/master protocol if both the
  18569.      slave and the master support it.  This variable was added in MySQL
  18570.      4.0.3.
  18571.  
  18572. `slave_net_timeout'
  18573.      The number of seconds to wait for more data from a master/slave
  18574.      connection before aborting the read.  This variable was added in
  18575.      MySQL 3.23.40.
  18576.  
  18577. `slow_launch_time'
  18578.      If creating a thread takes longer than this many seconds, the
  18579.      server increments the `Slow_launch_threads' status variable.  This
  18580.      variable was added in MySQL 3.23.15.
  18581.  
  18582. `socket'
  18583.      On Unix, this is the Unix socket file used for local client
  18584.      connections.  On Windows, this is the name of the named pipe used
  18585.      for local client connections.
  18586.  
  18587. `sort_buffer_size'
  18588.      Each thread that needs to do a sort allocates a buffer of this
  18589.      size. Increase this value for faster `ORDER BY' or `GROUP BY'
  18590.      operations.  *Note Temporary files::.
  18591.  
  18592. `sql_mode'
  18593.      The current server SQL mode.  This variable was added in MySQL
  18594.      3.23.41.  It can be set dynamically as of MySQL 4.1.1.  *Note
  18595.      Server SQL mode::.
  18596.  
  18597. `sql_slave_skip_counter'
  18598.      The number of events from the master that a slave server should
  18599.      skip.  It was added in MySQL 3.23.33.
  18600.  
  18601. `sql_updatable_view_key'
  18602.      This variable was added in MySQL 5.0.1.
  18603.  
  18604. `storage_engine'
  18605.      This variable is a synonym for `table_type'.  It was added in
  18606.      MySQL 4.1.2.
  18607.  
  18608. `sync_binlog'
  18609.      If positive, the MySQL server will synchronize its binary log to
  18610.      disk (`fdatasync()') after every `sync_binlog''th write to this
  18611.      binary log. Note that there is one write to the binary log per
  18612.      statement if in autocommit mode, and otherwise one write per
  18613.      transaction. The default value is 0 which does no sync'ing to
  18614.      disk. A value of 1 is the safest choice, because in case of crash
  18615.      you will lose at most one statement/transaction from the binary
  18616.      log; but it is also the slowest choice (unless the disk has a
  18617.      battery-backed cache, which makes sync'ing very fast). This
  18618.      variable was added in MySQL 4.1.3.
  18619.  
  18620. `sync_frm'
  18621.      This was added as a command-line option in MySQL 4.0.18, and is
  18622.      also a settable global variable since MySQL 4.1.3. If set to 1,
  18623.      when a non-temporary table is created it will synchronize its
  18624.      `.frm' file to disk (`fdatasync()'); this is slower but safer in
  18625.      case of crash. Default is 1.
  18626.  
  18627. `system_time_zone'
  18628.      The server system time zone. When the server starts, it attempts
  18629.      to determine the time zone of the host machine. For example, if
  18630.      the `TZ' environment variable is set, its value is used to set
  18631.      `system_time_zone'.  This variable was added in MySQL 4.1.3.
  18632.  
  18633. `table_cache'
  18634.      The number of open tables for all threads. Increasing this value
  18635.      increases the number of file descriptors that `mysqld' requires.
  18636.      You can check whether you need to increase the table cache by
  18637.      checking the `Opened_tables' status variable.  *Note Server status
  18638.      variables::.  If the value of `Opened_tables' is large and you
  18639.      don't do `FLUSH TABLES' a lot (which just forces all tables to be
  18640.      closed and reopened), then you should increase the value of the
  18641.      `table_cache' variable.
  18642.  
  18643.      For more information about the table cache, see *Note Table
  18644.      cache::.
  18645.  
  18646. `table_type'
  18647.      The default table type (storage engine).  To set the table type at
  18648.      server startup, use the `--default-table-type' option.  This
  18649.      variable was added in MySQL 3.23.0.  *Note Server options::.
  18650.  
  18651. `thread_cache_size'
  18652.      How many threads the server should cache for reuse.  When a client
  18653.      disconnects, the client's threads are put in the cache if there
  18654.      aren't already `thread_cache_size' threads there.  Requests for
  18655.      threads are satisfied by reusing threads taken from the cache if
  18656.      possible, and only when the cache is empty is a new thread
  18657.      created.  This variable can be increased to improve performance if
  18658.      you have a lot of new connections. (Normally this doesn't give a
  18659.      notable performance improvement if you have a good thread
  18660.      implementation.)  By examining the difference between the
  18661.      `Connections' and `Threads_created' status variables (*note Server
  18662.      status variables:: for details) you can see how efficient the
  18663.      thread cache is.  This variable was added in MySQL 3.23.16.
  18664.  
  18665. `thread_concurrency'
  18666.      On Solaris, `mysqld' calls `thr_setconcurrency()' with this value.
  18667.      This function allows applications to give the threads system a
  18668.      hint about the desired number of threads that should be run at the
  18669.      same time.  This variable was added in MySQL 3.23.7.
  18670.  
  18671. `thread_stack'
  18672.      The stack size for each thread.  Many of the limits detected by the
  18673.      `crash-me' test are dependent on this value. The default is large
  18674.      enough for normal operation.  *Note MySQL Benchmarks::.
  18675.  
  18676. `time_zone'
  18677.      The current time zone. The initial value of this is `'SYSTEM''
  18678.      (use the value of `system_time_zone'), but can be specified
  18679.      explicitly at server startup time with the `--default-time-zone'
  18680.      option.  This variable was added in MySQL 4.1.3.
  18681.  
  18682. `timezone'
  18683.      The time zone for the server.  This is set from the `TZ'
  18684.      environment variable when `mysqld' is started.  The time zone also
  18685.      can be set by giving a `--timezone' argument to `mysqld_safe'.
  18686.      This variable was added in MySQL 3.23.15. As of MySQL 4.1.3, it is
  18687.      obsolete and has been replaced by the `system_time_zone' variable.
  18688.      *Note Timezone problems::.
  18689.  
  18690. `tmp_table_size'
  18691.      If an in-memory temporary table exceeds this size, MySQL
  18692.      automatically converts it to an on-disk `MyISAM' table.  Increase
  18693.      the value of `tmp_table_size' if you do many advanced `GROUP BY'
  18694.      queries and you have lots of memory.
  18695.  
  18696. `tmpdir'
  18697.      The directory used for temporary files and temporary tables.
  18698.      Starting from MySQL 4.1, this variable can be set to a list of
  18699.      several paths that are used in round-robin fashion. Paths should
  18700.      be separated by colon characters (`:') on Unix and semicolon
  18701.      characters (`;') on Windows, NetWare, and OS/2.
  18702.  
  18703.      This feature can be used to spread the load between several
  18704.      physical disks.  If the MySQL server is acting as a replication
  18705.      slave, you should not set `tmpdir' to point to a directory on a
  18706.      memory-based filesystem or to a directory that is cleared when the
  18707.      server host restarts.  A replication slave needs some of its
  18708.      temporary files to survive a machine restart so that it can
  18709.      replicate temporary tables or `LOAD DATA INFILE' operations. If
  18710.      files in the temporary file directory are lost when the server
  18711.      restarts, replication will fail.
  18712.  
  18713.      This variable was added in MySQL 3.22.4.
  18714.  
  18715. `transaction_alloc_block_size'
  18716.      The allocation size of memory blocks that are allocated for
  18717.      storing queries that are part of a transaction to be stored in the
  18718.      binary log when doing a commit.  This variable was added in MySQL
  18719.      4.0.16.
  18720.  
  18721. `transaction_prealloc_size'
  18722.      The size of the persistent buffer for `transaction_alloc_blocks'
  18723.      that is not freed between queries. By making this big enough to
  18724.      fit all queries in a common transaction, you can avoid a lot of
  18725.      `malloc()' calls.  This variable was added in MySQL 4.0.16.
  18726.  
  18727. `tx_isolation'
  18728.      The default transaction isolation level.  This variable was added
  18729.      in MySQL 4.0.3.
  18730.  
  18731. `version'
  18732.      The version number for the server.
  18733.  
  18734. `version_bdb'
  18735.      The `BDB' storage engine version.  This variable was added in
  18736.      MySQL 3.23.31 with the name `bdb_version' and renamed to
  18737.      `version_bdb' in MySQL 4.1.1.
  18738.  
  18739. `version_comment'
  18740.      The `configure' script has a `--with-comment' option that allows a
  18741.      comment to be specified when building MySQL.  This variable
  18742.      contains the value of that comment.  This variable was added in
  18743.      MySQL 4.0.17.
  18744.  
  18745. `version_compile_machine'
  18746.      The type of machine MySQL was built on.  This variable was added
  18747.      in MySQL 4.1.1.
  18748.  
  18749. `version_compile_os'
  18750.      The type of operating system MySQL was built on.  This variable
  18751.      was added in MySQL 4.0.19.
  18752.  
  18753. `wait_timeout'
  18754.      The number of seconds the server waits for activity on a
  18755.      non-interactive connection before closing it.
  18756.  
  18757.      On thread startup, the session `wait_timeout' value is initialized
  18758.      from the global `wait_timeout' value or from the global
  18759.      `interactive_timeout' value, depending on the type of client (as
  18760.      defined by the `CLIENT_INTERACTIVE' connect option to
  18761.      `mysql_real_connect()'). See also `interactive_timeout'.
  18762.  
  18763. Dynamic System Variables
  18764. ........................
  18765.  
  18766. Beginning with MySQL 4.0.3, many server system variables are dynamic
  18767. and can be set at runtime using `SET GLOBAL' or `SET SESSION'. You can
  18768. also select their values using `SELECT'.  *Note System Variables::.
  18769.  
  18770. The following table shows the full list of all dynamic system variables.
  18771. The last column indicates for each variable whether `GLOBAL' or
  18772. `SESSION' (or both) apply.
  18773.  
  18774. *Variable Name*                  *Value Type*       *Type*
  18775. `autocommit'                     boolean            `SESSION'
  18776. `big_tables'                     boolean            `SESSION'
  18777. `binlog_cache_size'              numeric            `GLOBAL'
  18778. `bulk_insert_buffer_size'        numeric            `GLOBAL' | `SESSION'
  18779. `character_set_client'           string             `GLOBAL' | `SESSION'
  18780. `character_set_connection'       string             `GLOBAL' | `SESSION'
  18781. `character_set_results'          string             `GLOBAL' | `SESSION'
  18782. `character_set_server'           string             `GLOBAL' | `SESSION'
  18783. `collation_connection'           string             `GLOBAL' | `SESSION'
  18784. `collation_server'               string             `GLOBAL' | `SESSION'
  18785. `concurrent_insert'              boolean            `GLOBAL'
  18786. `connect_timeout'                numeric            `GLOBAL'
  18787. `convert_character_set'          string             `GLOBAL' | `SESSION'
  18788. `default_week_format'            numeric            `GLOBAL' | `SESSION'
  18789. `delay_key_write'                `OFF' | `ON' |     `GLOBAL'
  18790.                                  `ALL'              
  18791. `delayed_insert_limit'           numeric            `GLOBAL'
  18792. `delayed_insert_timeout'         numeric            `GLOBAL'
  18793. `delayed_queue_size'             numeric            `GLOBAL'
  18794. `error_count'                    numeric            `SESSION'
  18795. `expire_logs_days'               numeric            `GLOBAL'
  18796. `flush'                          boolean            `GLOBAL'
  18797. `flush_time'                     numeric            `GLOBAL'
  18798. `foreign_key_checks'             boolean            `SESSION'
  18799. `ft_boolean_syntax'              numeric            `GLOBAL'
  18800. `group_concat_max_len'           numeric            `GLOBAL' | `SESSION'
  18801. `identity'                       numeric            `SESSION'
  18802. `insert_id'                      boolean            `SESSION'
  18803. `interactive_timeout'            numeric            `GLOBAL' | `SESSION'
  18804. `join_buffer_size'               numeric            `GLOBAL' | `SESSION'
  18805. `key_buffer_size'                numeric            `GLOBAL'
  18806. `last_insert_id'                 numeric            `SESSION'
  18807. `local_infile'                   boolean            `GLOBAL'
  18808. `log_warnings'                   numeric            `GLOBAL'
  18809. `long_query_time'                numeric            `GLOBAL' | `SESSION'
  18810. `low_priority_updates'           boolean            `GLOBAL' | `SESSION'
  18811. `max_allowed_packet'             numeric            `GLOBAL' | `SESSION'
  18812. `max_binlog_cache_size'          numeric            `GLOBAL'
  18813. `max_binlog_size'                numeric            `GLOBAL'
  18814. `max_connect_errors'             numeric            `GLOBAL'
  18815. `max_connections'                numeric            `GLOBAL'
  18816. `max_delayed_threads'            numeric            `GLOBAL'
  18817. `max_error_count'                numeric            `GLOBAL' | `SESSION'
  18818. `max_heap_table_size'            numeric            `GLOBAL' | `SESSION'
  18819. `max_insert_delayed_threads'     numeric            `GLOBAL'
  18820. `max_join_size'                  numeric            `GLOBAL' | `SESSION'
  18821. `max_relay_log_size'             numeric            `GLOBAL'
  18822. `max_seeks_for_key'              numeric            `GLOBAL' | `SESSION'
  18823. `max_sort_length'                numeric            `GLOBAL' | `SESSION'
  18824. `max_tmp_tables'                 numeric            `GLOBAL' | `SESSION'
  18825. `max_user_connections'           numeric            `GLOBAL'
  18826. `max_write_lock_count'           numeric            `GLOBAL'
  18827. `myisam_data_pointer_size'       numeric            `GLOBAL'
  18828. `myisam_max_extra_sort_file_size'numeric            `GLOBAL' | `SESSION'
  18829. `myisam_max_sort_file_size'      numeric            `GLOBAL' | `SESSION'
  18830. `myisam_repair_threads'          numeric            `GLOBAL' | `SESSION'
  18831. `myisam_sort_buffer_size'        numeric            `GLOBAL' | `SESSION'
  18832. `net_buffer_length'              numeric            `GLOBAL' | `SESSION'
  18833. `net_read_timeout'               numeric            `GLOBAL' | `SESSION'
  18834. `net_retry_count'                numeric            `GLOBAL' | `SESSION'
  18835. `net_write_timeout'              numeric            `GLOBAL' | `SESSION'
  18836. `old_passwords'                  numeric            `GLOBAL' | `SESSION'
  18837. `optimizer_prune_level'          numeric            `GLOBAL' | `SESSION'
  18838. `optimizer_search_depth'         numeric            `GLOBAL' | `SESSION'
  18839. `preload_buffer_size'            numeric            `GLOBAL' | `SESSION'
  18840. `query_alloc_block_size'         numeric            `GLOBAL' | `SESSION'
  18841. `query_cache_limit'              numeric            `GLOBAL'
  18842. `query_cache_size'               numeric            `GLOBAL'
  18843. `query_cache_type'               enumeration        `GLOBAL' | `SESSION'
  18844. `query_cache_wlock_invalidate'   boolean            `GLOBAL' | `SESSION'
  18845. `query_prealloc_size'            numeric            `GLOBAL' | `SESSION'
  18846. `range_alloc_block_size'         numeric            `GLOBAL' | `SESSION'
  18847. `read_buffer_size'               numeric            `GLOBAL' | `SESSION'
  18848. `read_only'                      numeric            `GLOBAL'
  18849. `read_rnd_buffer_size'           numeric            `GLOBAL' | `SESSION'
  18850. `rpl_recovery_rank'              numeric            `GLOBAL'
  18851. `safe_show_database'             boolean            `GLOBAL'
  18852. `secure_auth'                    boolean            `GLOBAL'
  18853. `server_id'                      numeric            `GLOBAL'
  18854. `slave_compressed_protocol'      boolean            `GLOBAL'
  18855. `slave_net_timeout'              numeric            `GLOBAL'
  18856. `slow_launch_time'               numeric            `GLOBAL'
  18857. `sort_buffer_size'               numeric            `GLOBAL' | `SESSION'
  18858. `sql_auto_is_null'               boolean            `SESSION'
  18859. `sql_big_selects'                boolean            `SESSION'
  18860. `sql_big_tables'                 boolean            `SESSION'
  18861. `sql_buffer_result'              boolean            `SESSION'
  18862. `sql_log_bin'                    boolean            `SESSION'
  18863. `sql_log_off'                    boolean            `SESSION'
  18864. `sql_log_update'                 boolean            `SESSION'
  18865. `sql_low_priority_updates'       boolean            `GLOBAL' | `SESSION'
  18866. `sql_max_join_size'              numeric            `GLOBAL' | `SESSION'
  18867. `sql_mode'                       enumeration        `GLOBAL' | `SESSION'
  18868. `sql_quote_show_create'          boolean            `SESSION'
  18869. `sql_safe_updates'               boolean            `SESSION'
  18870. `sql_select_limit'               numeric            `SESSION'
  18871. `sql_slave_skip_counter'         numeric            `GLOBAL'
  18872. `sql_updatable_view_key'         enumeration        `GLOBAL' | `SESSION'
  18873. `sql_warnings'                   boolean            `SESSION'
  18874. `sync_binlog'                    numeric            `GLOBAL'
  18875. `sync_frm'                       boolean            `GLOBAL'
  18876. `storage_engine'                 enumeration        `GLOBAL' | `SESSION'
  18877. `table_cache'                    numeric            `GLOBAL'
  18878. `table_type'                     enumeration        `GLOBAL' | `SESSION'
  18879. `thread_cache_size'              numeric            `GLOBAL'
  18880. `time_zone'                      string             `GLOBAL' | `SESSION'
  18881. `timestamp'                      boolean            `SESSION'
  18882. `tmp_table_size'                 enumeration        `GLOBAL' | `SESSION'
  18883. `transaction_alloc_block_size'   numeric            `GLOBAL' | `SESSION'
  18884. `transaction_prealloc_size'      numeric            `GLOBAL' | `SESSION'
  18885. `tx_isolation'                   enumeration        `GLOBAL' | `SESSION'
  18886. `unique_checks'                  boolean            `SESSION'
  18887. `wait_timeout'                   numeric            `GLOBAL' | `SESSION'
  18888. `warning_count'                  numeric            `SESSION'
  18889.  
  18890. Variables that are marked as "string" take a string value.  Variables
  18891. that are marked as "numeric" take a numeric value. Variables that are
  18892. marked as "boolean" can be set to 0, 1, `ON' or `OFF'. Variables that
  18893. are marked as "enumeration" normally should be set to one of the
  18894. available values for the variable, but can also be set to the number
  18895. that corresponds to the desired enumeration value.  For
  18896. enumeration-valued system variables, the first enumeration value
  18897. corresponds to 0. This differs from `ENUM' columns, for which the first
  18898. enumeration value corresponds to 1.
  18899.  
  18900. Server Status Variables
  18901. -----------------------
  18902.  
  18903. The server maintains many status variables that provide information
  18904. about its operations. You can view these variables and their values by
  18905. using the `SHOW STATUS' statement:
  18906.  
  18907.      mysql> SHOW STATUS;
  18908.      +--------------------------+------------+
  18909.      | Variable_name            | Value      |
  18910.      +--------------------------+------------+
  18911.      | Aborted_clients          | 0          |
  18912.      | Aborted_connects         | 0          |
  18913.      | Bytes_received           | 155372598  |
  18914.      | Bytes_sent               | 1176560426 |
  18915.      | Connections              | 30023      |
  18916.      | Created_tmp_disk_tables  | 0          |
  18917.      | Created_tmp_files        | 60         |
  18918.      | Created_tmp_tables       | 8340       |
  18919.      | Delayed_errors           | 0          |
  18920.      | Delayed_insert_threads   | 0          |
  18921.      | Delayed_writes           | 0          |
  18922.      | Flush_commands           | 1          |
  18923.      | Handler_delete           | 462604     |
  18924.      | Handler_read_first       | 105881     |
  18925.      | Handler_read_key         | 27820558   |
  18926.      | Handler_read_next        | 390681754  |
  18927.      | Handler_read_prev        | 6022500    |
  18928.      | Handler_read_rnd         | 30546748   |
  18929.      | Handler_read_rnd_next    | 246216530  |
  18930.      | Handler_update           | 16945404   |
  18931.      | Handler_write            | 60356676   |
  18932.      | Key_blocks_used          | 14955      |
  18933.      | Key_read_requests        | 96854827   |
  18934.      | Key_reads                | 162040     |
  18935.      | Key_write_requests       | 7589728    |
  18936.      | Key_writes               | 3813196    |
  18937.      | Max_used_connections     | 0          |
  18938.      | Not_flushed_delayed_rows | 0          |
  18939.      | Not_flushed_key_blocks   | 0          |
  18940.      | Open_files               | 2          |
  18941.      | Open_streams             | 0          |
  18942.      | Open_tables              | 1          |
  18943.      | Opened_tables            | 44600      |
  18944.      | Qcache_free_blocks       | 36         |
  18945.      | Qcache_free_memory       | 138488     |
  18946.      | Qcache_hits              | 79570      |
  18947.      | Qcache_inserts           | 27087      |
  18948.      | Qcache_lowmem_prunes     | 3114       |
  18949.      | Qcache_not_cached        | 22989      |
  18950.      | Qcache_queries_in_cache  | 415        |
  18951.      | Qcache_total_blocks      | 912        |
  18952.      | Questions                | 2026873    |
  18953.      | Select_full_join         | 0          |
  18954.      | Select_full_range_join   | 0          |
  18955.      | Select_range             | 99646      |
  18956.      | Select_range_check       | 0          |
  18957.      | Select_scan              | 30802      |
  18958.      | Slave_open_temp_tables   | 0          |
  18959.      | Slave_running            | OFF        |
  18960.      | Slow_launch_threads      | 0          |
  18961.      | Slow_queries             | 0          |
  18962.      | Sort_merge_passes        | 30         |
  18963.      | Sort_range               | 500        |
  18964.      | Sort_rows                | 30296250   |
  18965.      | Sort_scan                | 4650       |
  18966.      | Table_locks_immediate    | 1920382    |
  18967.      | Table_locks_waited       | 0          |
  18968.      | Threads_cached           | 0          |
  18969.      | Threads_connected        | 1          |
  18970.      | Threads_created          | 30022      |
  18971.      | Threads_running          | 1          |
  18972.      | Uptime                   | 80380      |
  18973.      +--------------------------+------------+
  18974.  
  18975. Many status variables are reset to 0 by the `FLUSH STATUS' statement.
  18976.  
  18977. The status variables have the following meanings.  The `Com_XXX'
  18978. statement counter variables were added beginning with MySQL 3.23.47. The
  18979. `Qcache_XXX' query cache variables were added beginning with MySQL
  18980. 4.0.1. Otherwise, variables with no version indicated have been present
  18981. since at least MySQL 3.22.
  18982.  
  18983. `Aborted_clients'
  18984.      The number of connections that were aborted because the client
  18985.      died without closing the connection properly.  *Note Communication
  18986.      errors::.
  18987.  
  18988. `Aborted_connects'
  18989.      The number of tries to connect to the MySQL server that failed.
  18990.      *Note Communication errors::.
  18991.  
  18992. `Binlog_cache_disk_use'
  18993.      The number of transactions that used the temporary binary log
  18994.      cache but that exceeded the value of `binlog_cache_size' and used
  18995.      a temporary file to store statements from the transaction.  This
  18996.      variable was added in MySQL 4.1.2.
  18997.  
  18998. `Binlog_cache_use'
  18999.      The number of transactions that used the temporary binary log
  19000.      cache.  This variable was added in MySQL 4.1.2.
  19001.  
  19002. `Bytes_received'
  19003.      The number of bytes received from all clients.  This variable was
  19004.      added in MySQL 3.23.7.
  19005.  
  19006. `Bytes_sent'
  19007.      The number of bytes sent to all clients.  This variable was added
  19008.      in MySQL 3.23.7.
  19009.  
  19010. `Com_XXX'
  19011.      The number of times each XXX statement has been executed.  There
  19012.      is one status variable for each type of statement. For example,
  19013.      `Com_delete' and `Com_insert' count `DELETE' and `INSERT'
  19014.      statements.
  19015.  
  19016. `Connections'
  19017.      The number of connection attempts (successful or not) to the MySQL
  19018.      server.
  19019.  
  19020. `Created_tmp_disk_tables'
  19021.      The number of temporary tables on disk created automatically by
  19022.      the server while executing statements.  This variable was added in
  19023.      MySQL 3.23.24.
  19024.  
  19025. `Created_tmp_files'
  19026.      How many temporary files `mysqld' has created.  This variable was
  19027.      added in MySQL 3.23.28.
  19028.  
  19029. `Created_tmp_tables'
  19030.      The number of in-memory temporary tables created automatically by
  19031.      the server while executing statements.  If
  19032.      `Created_tmp_disk_tables' is big, you may want to increase the
  19033.      `tmp_table_size' value to cause temporary tables to be memory-based
  19034.      instead of disk-based.
  19035.  
  19036. `Delayed_errors'
  19037.      The number of rows written with `INSERT DELAYED' for which some
  19038.      error occurred (probably `duplicate key').
  19039.  
  19040. `Delayed_insert_threads'
  19041.      The number of `INSERT DELAYED' handler threads in use.
  19042.  
  19043. `Delayed_writes'
  19044.      The number of `INSERT DELAYED' rows written.
  19045.  
  19046. `Flush_commands'
  19047.      The number of executed `FLUSH' statements.
  19048.  
  19049. `Handler_commit'
  19050.      The number of internal `COMMIT' statements.  This variable was
  19051.      added in MySQL 4.0.2.
  19052.  
  19053. `Handler_discover'
  19054.      The MySQL server can ask the `NDBCluster' storage engine if it
  19055.      knows about a table with a given name. This is called discovery.
  19056.      `Handler_discover' indicates the number of time tables have been
  19057.      discovered.  This variable was added in MySQL 4.1.2.
  19058.  
  19059. `Handler_delete'
  19060.      The number of times a row was deleted from a table.
  19061.  
  19062. `Handler_read_first'
  19063.      The number of times the first entry was read from an index.  If
  19064.      this is high, it suggests that the server is doing a lot of full
  19065.      index scans; for example, `SELECT col1 FROM foo', assuming that
  19066.      `col1' is indexed.
  19067.  
  19068. `Handler_read_key'
  19069.      The number of requests to read a row based on a key. If this is
  19070.      high, it is a good indication that your queries and tables are
  19071.      properly indexed.
  19072.  
  19073. `Handler_read_next'
  19074.      The number of requests to read the next row in key order. This
  19075.      will be incremented if you are querying an index column with a
  19076.      range constraint or if you are doing an index scan.
  19077.  
  19078. `Handler_read_prev'
  19079.      The number of requests to read the previous row in key order.
  19080.      This read method is mainly used to optimize `ORDER BY ... DESC'.
  19081.      This variable was added in MySQL 3.23.6.
  19082.  
  19083. `Handler_read_rnd'
  19084.      The number of requests to read a row based on a fixed position.
  19085.      This will be high if you are doing a lot of queries that require
  19086.      sorting of the result.  You probably have a lot of queries that
  19087.      require MySQL to scan whole tables or you have joins that don't
  19088.      use keys properly.
  19089.  
  19090. `Handler_read_rnd_next'
  19091.      The number of requests to read the next row in the data file.
  19092.      This will be high if you are doing a lot of table scans. Generally
  19093.      this suggests that your tables are not properly indexed or that
  19094.      your queries are not written to take advantage of the indexes you
  19095.      have.
  19096.  
  19097. `Handler_rollback'
  19098.      The number of internal `ROLLBACK' statements.  This variable was
  19099.      added in MySQL 4.0.2.
  19100.  
  19101. `Handler_update'
  19102.      The number of requests to update a row in a table.
  19103.  
  19104. `Handler_write'
  19105.      The number of requests to insert a row in a table.
  19106.  
  19107. `Key_blocks_not_flushed'
  19108.      The number of key blocks in the key cache that have changed but
  19109.      haven't yet been flushed to disk.  This variable was added in
  19110.      MySQL 4.1.1.  It used to be known as `Not_flushed_key_blocks'.
  19111.  
  19112. `Key_blocks_unused'
  19113.      This variable was added in MySQL 4.1.2.  *Note Server system
  19114.      variables::.
  19115.  
  19116. `Key_blocks_used'
  19117.      The number of used blocks in the key cache.  You can use this
  19118.      value to determine how much of the key cache is in use; see the
  19119.      discussion of `key_buffer_size' in *Note Server system variables::.
  19120.  
  19121. `Key_read_requests'
  19122.      The number of requests to read a key block from the cache.
  19123.  
  19124. `Key_reads'
  19125.      The number of physical reads of a key block from disk.  If
  19126.      `Key_reads' is big, then your `key_buffer_size' value is probably
  19127.      too small.  The cache miss rate can be calculated as
  19128.      `Key_reads'/`Key_read_requests'.
  19129.  
  19130. `Key_write_requests'
  19131.      The number of requests to write a key block to the cache.
  19132.  
  19133. `Key_writes'
  19134.      The number of physical writes of a key block to disk.
  19135.  
  19136. `Last_query_cost'
  19137.      The total cost of the last compiled query as computed by the query
  19138.      optimizer. Useful for comparing the cost of different query plans
  19139.      for the same query. The default value of -1 means that no query
  19140.      has been compiled yet. This variable was added in MySQL 5.0.1.
  19141.  
  19142. `Max_used_connections'
  19143.      The maximum number of connections that have been in use
  19144.      simultaneously since the server started.
  19145.  
  19146. `Not_flushed_delayed_rows'
  19147.      The number of rows waiting to be written in `INSERT DELAY' queues.
  19148.  
  19149. `Not_flushed_key_blocks'
  19150.      The old name for `Key_blocks_not_flushed' before MySQL 4.1.1.
  19151.  
  19152. `Open_files'
  19153.      The number of files that are open.
  19154.  
  19155. `Open_streams'
  19156.      The number of streams that are open (used mainly for logging).
  19157.  
  19158. `Open_tables'
  19159.      The number of tables that are open.
  19160.  
  19161. `Opened_tables'
  19162.      The number of tables that have been opened.  If `Opened_tables' is
  19163.      big, your `table_cache' value is probably too small.
  19164.  
  19165. `Qcache_free_blocks'
  19166.      The number of free memory blocks in query cache.
  19167.  
  19168. `Qcache_free_memory'
  19169.      The amount of free memory for query cache.
  19170.  
  19171. `Qcache_hits'
  19172.      The number of cache hits.
  19173.  
  19174. `Qcache_inserts'
  19175.      The number of queries added to the cache.
  19176.  
  19177. `Qcache_lowmem_prunes'
  19178.      The number of queries that were deleted from the cache because of
  19179.      low memory.
  19180.  
  19181. `Qcache_not_cached'
  19182.      The number of non-cached queries (not cachable, or due to
  19183.      `query_cache_type').
  19184.  
  19185. `Qcache_queries_in_cache'
  19186.      The number of queries registered in the cache.
  19187.  
  19188. `Qcache_total_blocks'
  19189.      The total number of blocks in the query cache.
  19190.  
  19191. `Questions'
  19192.      The number of queries that have been sent to the server.
  19193.  
  19194. `Rpl_status'
  19195.      The status of failsafe replication (not yet implemented).
  19196.  
  19197. `Select_full_join'
  19198.      The number of joins that do not use indexes.  If this value is not
  19199.      0, you should carefully check the indexes of your tables.  This
  19200.      variable was added in MySQL 3.23.25.
  19201.  
  19202. `Select_full_range_join'
  19203.      The number of joins that used a range search on a reference table.
  19204.      This variable was added in MySQL 3.23.25.
  19205.  
  19206. `Select_range'
  19207.      The number of joins that used ranges on the first table. (It's
  19208.      normally not critical even if this is big.)  This variable was
  19209.      added in MySQL 3.23.25.
  19210.  
  19211. `Select_range_check'
  19212.      The number of joins without keys that check for key usage after
  19213.      each row.  (If this is not 0, you should carefully check the
  19214.      indexes of your tables.)  This variable was added in MySQL 3.23.25.
  19215.  
  19216. `Select_scan'
  19217.      The number of joins that did a full scan of the first table.  This
  19218.      variable was added in MySQL 3.23.25.
  19219.  
  19220. `Slave_open_temp_tables'
  19221.      The number of temporary tables currently open by the slave SQL
  19222.      thread.  This variable was added in MySQL 3.23.29.
  19223.  
  19224. `Slave_running'
  19225.      This is `ON' if this server is a slave that is connected to a
  19226.      master.  This variable was added in MySQL 3.23.16.
  19227.  
  19228. `Slow_launch_threads'
  19229.      The number of threads that have taken more than `slow_launch_time'
  19230.      seconds to create.  This variable was added in MySQL 3.23.15.
  19231.  
  19232. `Slow_queries'
  19233.      The number of queries that have taken more than `long_query_time'
  19234.      seconds. *Note Slow query log::.
  19235.  
  19236. `Sort_merge_passes'
  19237.      The number of merge passes the sort algorithm has had to do. If
  19238.      this value is large, you should consider increasing the value of
  19239.      the `sort_buffer_size' system variable.  This variable was added
  19240.      in MySQL 3.23.28.
  19241.  
  19242. `Sort_range'
  19243.      The number of sorts that were done with ranges.  This variable was
  19244.      added in MySQL 3.23.25.
  19245.  
  19246. `Sort_rows'
  19247.      The number of sorted rows.  This variable was added in MySQL
  19248.      3.23.25.
  19249.  
  19250. `Sort_scan'
  19251.      The number of sorts that were done by scanning the table.  This
  19252.      variable was added in MySQL 3.23.25.
  19253.  
  19254. `Ssl_XXX'
  19255.      Variables used for SSL connections.  These variables were added in
  19256.      MySQL 4.0.0.
  19257.  
  19258. `Table_locks_immediate'
  19259.      The number of times that a table lock was acquired immediately.
  19260.      This variable was added as of MySQL 3.23.33.
  19261.  
  19262. `Table_locks_waited'
  19263.      The number of times that a table lock could not be acquired
  19264.      immediately and a wait was needed. If this is high, and you have
  19265.      performance problems, you should first optimize your queries, and
  19266.      then either split your table or tables or use replication.  This
  19267.      variable was added as of MySQL 3.23.33.
  19268.  
  19269. `Threads_cached'
  19270.      The number of threads in the thread cache.  This variable was
  19271.      added in MySQL 3.23.17.
  19272.  
  19273. `Threads_connected'
  19274.      The number of currently open connections.
  19275.  
  19276. `Threads_created'
  19277.      The number of threads created to handle connections.  If
  19278.      `Threads_created' is big, you may want to increase the
  19279.      `thread_cache_size' value.  The cache hit rate can be calculated
  19280.      as `Threads_created'/`Connections'.  This variable was added in
  19281.      MySQL 3.23.31.
  19282.  
  19283. `Threads_running'
  19284.      The number of threads that are not sleeping.
  19285.  
  19286. `Uptime'
  19287.      The number of seconds the server has been up.
  19288.  
  19289. The MySQL Server Shutdown Process
  19290. =================================
  19291.  
  19292. The server shutdown process can be summarized like this:
  19293.  
  19294.   1. The shutdown process is initiated
  19295.  
  19296.   2. The server creates a shutdown thread if necessary
  19297.  
  19298.   3. The server stops accepting new connections
  19299.  
  19300.   4. The server terminates current activity
  19301.  
  19302.   5. Storage engines are shut down or closed
  19303.  
  19304.   6. The server exits
  19305.  
  19306. A more detailed description of the process follows:
  19307.  
  19308.   1. The shutdown process is initiated
  19309.  
  19310.      Server shutdown can be initiated several ways. For example, a user
  19311.      with the `SHUTDOWN' privilege can execute a `mysqladmin shutdown'
  19312.      command. `mysqladmin' can be used on any platform supported by
  19313.      MySQL. Other operating sytem-specific shutdown initiation methods
  19314.      are possible as well: The server shuts down on Unix when it
  19315.      receives a `SIGTERM' signal. A server running as a service on
  19316.      Windows shuts down when the services manager tells it to.
  19317.  
  19318.   2. The server creates a shutdown thread if necessary
  19319.  
  19320.      Depending on how shutdown was initiated, the server might create a
  19321.      thread to handle the shutdown process.  If shutdown was requested
  19322.      by a client, a shutdown thread is created.  If shutdown is the
  19323.      result of receiving a `SIGTERM' signal, the signal thread might
  19324.      handle shutdown itself, or it might create a separate thread to do
  19325.      so.  If the server tries to create a shutdown thread and cannot
  19326.      (for example, if memory is exhausted), it issues a diagnostic
  19327.      message that will appear in the error log:
  19328.  
  19329.           Error: Can't create thread to kill server
  19330.  
  19331.   3. The server stops accepting new connections
  19332.  
  19333.      To prevent new activity from being initiated during shutdown, the
  19334.      server stops accepting new client connections. It does this by
  19335.      closing the network connections to which it normally listens for
  19336.      connections: the TCP/IP port, the Unix socket file, the Windows
  19337.      named pipe.
  19338.  
  19339.   4. The server terminates current activity
  19340.  
  19341.      For each thread that is associated with a client connection, the
  19342.      connection to the client is broken and the thread is marked as
  19343.      killed. Threads die when they notice that they are so marked.
  19344.      Threads for idle connections die quickly. Threads that currently
  19345.      are processing queries check their state periodically and take
  19346.      longer to die.  For additional information about thread
  19347.      termination, see *Note `KILL': KILL, in particular for the
  19348.      instructions about killed `REPAIR TABLE' or `OPTIMIZE TABLE'
  19349.      operations on `MyISAM' tables.
  19350.  
  19351.      For threads that have an open transaction, the tranaction is
  19352.      rolled back.  Note that if a thread is updating a
  19353.      non-transactional table, an operation such as a multiple-row
  19354.      `UPDATE' or `INSERT' may leave the table partially updated,
  19355.      because the operation can terminate before completion.
  19356.  
  19357.      If the server is a master replication server, threads associated
  19358.      with currently connected slaves are treated like other client
  19359.      threads. That is, each one is marked as killed and exits when it
  19360.      next checks its state.
  19361.  
  19362.      If the server is a slave replication server, the I/O and SQL
  19363.      threads, if active, are stopped before client threads are marked
  19364.      as killed. The SQL thread is allowed to finish its current
  19365.      statement (to avoid causing replication problems) then stops. If
  19366.      the SQL thread was in the middle of a transaction at this point,
  19367.      the transaction is rolled back.
  19368.  
  19369.   5. Storage engines are shut down or closed
  19370.  
  19371.      At this stage, the table cache is flushed and all open tables are
  19372.      closed.
  19373.  
  19374.      Each storage engine performs any actions necessary for tables that
  19375.      it manages.  For example, MyISAM flushes any pending index writes
  19376.      for a table.  InnoDB flushes its buffer pool to disk, writes the
  19377.      current LSN to the tablespace, and terminates its own internal
  19378.      threads.
  19379.  
  19380.   6. The server exits
  19381.  
  19382.  
  19383. General Security Issues
  19384. =======================
  19385.  
  19386. This section describes some general security issues to be aware of and
  19387. what you can do to make your MySQL installation more secure against
  19388. attack or misuse. For information specifically about the access control
  19389. system that MySQL uses for setting up user accounts and checking
  19390. database access, see *Note Privilege system::.
  19391.  
  19392. General Security Guidelines
  19393. ---------------------------
  19394.  
  19395. Anyone using MySQL on a computer connected to the Internet should read
  19396. this section to avoid the most common security mistakes.
  19397.  
  19398. In discussing security, we emphasize the necessity of fully protecting
  19399. the entire server host (not just the MySQL server) against all types of
  19400. applicable attacks: eavesdropping, altering, playback, and denial of
  19401. service. We do not cover all aspects of availability and fault tolerance
  19402. here.
  19403.  
  19404. MySQL uses security based on Access Control Lists (ACLs) for all
  19405. connections, queries, and other operations that users can attempt to
  19406. perform. There is also some support for SSL-encrypted connections
  19407. between MySQL clients and servers. Many of the concepts discussed here
  19408. are not specific to MySQL at all; the same general ideas apply to
  19409. almost all applications.
  19410.  
  19411. When running MySQL, follow these guidelines whenever possible:
  19412.  
  19413.    * *Do not ever give anyone (except MySQL `root' accounts) access to
  19414.      the `user' table in the `mysql' database!*  This is critical.
  19415.      *The encrypted password is the real password in MySQL.* Anyone who
  19416.      knows the password that is listed in the `user' table and has
  19417.      access to the host listed for the account *can easily log in as
  19418.      that user*.
  19419.  
  19420.    * Learn the MySQL access privilege system. The `GRANT' and `REVOKE'
  19421.      statements are used for controlling access to MySQL. Do not grant
  19422.      any more privileges than necessary. Never grant privileges to all
  19423.      hosts.
  19424.  
  19425.      Checklist:
  19426.         - Try `mysql -u root'. If you are able to connect successfully
  19427.           to the server without being asked for a password, you have
  19428.           problems. Anyone can connect to your MySQL server as the MySQL
  19429.           `root' user with full privileges!  Review the MySQL
  19430.           installation instructions, paying particular attention to the
  19431.           information about setting a `root' password.  *Note Default
  19432.           privileges::.
  19433.  
  19434.         - Use the `SHOW GRANTS' statement and check to see who has
  19435.           access to what.  Then use the `REVOKE' statement to remove
  19436.           those privileges that are not necessary.
  19437.  
  19438.    * Do not store any plain-text passwords in your database. If your
  19439.      computer becomes compromised, the intruder can take the full list
  19440.      of passwords and use them. Instead, use `MD5()', `SHA1()', or some
  19441.      other one-way hashing function.
  19442.  
  19443.    * Do not choose passwords from dictionaries. There are special
  19444.      programs to break them. Even passwords like "xfish98" are very
  19445.      bad.  Much better is "duag98" which contains the same word "fish"
  19446.      but typed one key to the left on a standard QWERTY keyboard.
  19447.      Another method is to use "Mhall" which is taken from the first
  19448.      characters of each word in the sentence "Mary had a little lamb."
  19449.      This is easy to remember and type, but difficult to guess for
  19450.      someone who does not know it.
  19451.  
  19452.    * Invest in a firewall. This protects you from at least 50% of all
  19453.      types of exploits in any software. Put MySQL behind the firewall
  19454.      or in a demilitarized zone (DMZ).
  19455.  
  19456.      Checklist:
  19457.         - Try to scan your ports from the Internet using a tool such as
  19458.           `nmap'. MySQL uses port 3306 by default. This port should not
  19459.           be accessible from untrusted hosts. Another simple way to
  19460.           check whether or not your MySQL port is open is to try the
  19461.           following command from some remote machine, where
  19462.           `server_host' is the host on which your MySQL server runs:
  19463.  
  19464.                shell> telnet server_host 3306
  19465.  
  19466.           If you get a connection and some garbage characters, the port
  19467.           is open, and should be closed on your firewall or router,
  19468.           unless you really have a good reason to keep it open. If
  19469.           `telnet' just hangs or the connection is refused, everything
  19470.           is OK; the port is blocked.
  19471.  
  19472.    * Do not trust any data entered by users of your applications. They
  19473.      can try to trick your code by entering special or escaped
  19474.      character sequences in Web forms, URLs, or whatever application
  19475.      you have built. Be sure that your application remains secure if a
  19476.      user enters something like "`; DROP DATABASE mysql;'". This is an
  19477.      extreme example, but large security leaks and data loss might
  19478.      occur as a result of hackers using similar techniques, if you do
  19479.      not prepare for them.
  19480.  
  19481.      A common mistake is to protect only string data values.  Remember
  19482.      to check numeric data as well.  If an application generates a
  19483.      query such as `SELECT * FROM table WHERE ID=234' when a user
  19484.      enters the value `234', the user can enter the value `234 OR 1=1'
  19485.      to cause the application to generate the query `SELECT * FROM
  19486.      table WHERE ID=234 OR 1=1'.  As a result, the server retrieves
  19487.      every record in the table.  This exposes every record and causes
  19488.      excessive server load.  The simplest way to protect from this type
  19489.      of attack is to use apostrophes around the numeric constants:
  19490.      `SELECT * FROM table WHERE ID='234''. If the user enters extra
  19491.      information, it all becomes part of the string. In numeric context,
  19492.      MySQL automatically converts this string to a number and strips
  19493.      any trailing non-numeric characters from it.
  19494.  
  19495.      Sometimes people think that if a database contains only publicly
  19496.      available data, it need not be protected. This is incorrect.  Even
  19497.      if it is allowable to display any record in the database, you
  19498.      should still protect against denial of service attacks (for
  19499.      example, those that are based on the technique in the preceding
  19500.      paragraph that causes the server to waste resources). Otherwise,
  19501.      your server becomes unresponsive to legitimate users.
  19502.  
  19503.      Checklist:
  19504.         - Try to enter `'' and `"' in all your Web forms. If you get
  19505.           any kind of MySQL error, investigate the problem right away.
  19506.  
  19507.         - Try to modify any dynamic URLs by adding `%22' (`"'), `%23'
  19508.           (`#'), and `%27' (`'') in the URL.
  19509.  
  19510.         - Try to modify data types in dynamic URLs from numeric ones to
  19511.           character ones containing characters from previous examples.
  19512.           Your application should be safe against this and similar
  19513.           attacks.
  19514.  
  19515.         - Try to enter characters, spaces, and special symbols rather
  19516.           than numbers in numeric fields. Your application should
  19517.           remove them before passing them to MySQL or else generate an
  19518.           error. Passing unchecked values to MySQL is very dangerous!
  19519.  
  19520.         - Check data sizes before passing them to MySQL.
  19521.  
  19522.         - Consider having your application connect to the database
  19523.           using a different username than the one you use for
  19524.           administrative purposes. Do not give your applications any
  19525.           access privileges they do not need.
  19526.  
  19527.    * Many application programming interfaces provide a means of
  19528.      escaping special characters in data values. Properly used, this
  19529.      prevents application users from entering values that cause the
  19530.      application to generate statements that have a different effect
  19531.      than you intend:
  19532.         - MySQL C API: Use the `mysql_real_escape_string()' API call.
  19533.  
  19534.         - MySQL++: Use the `escape' and `quote' modifiers for query
  19535.           streams.
  19536.  
  19537.         - PHP: Use the `mysql_escape_string()' function, which is based
  19538.           on the function of the same name in the MySQL C API.  Prior
  19539.           to PHP 4.0.3, use  `addslashes()' instead.
  19540.  
  19541.         - Perl DBI: Use the `quote()' method or use placeholders.
  19542.  
  19543.         - Java JDBC: Use a `PreparedStatement' object and placeholders.
  19544.  
  19545.      Other programming interfaces might have similar capabilities.
  19546.  
  19547.    * Do not transmit plain (unencrypted) data over the Internet. This
  19548.      information is accessible to everyone who has the time and ability
  19549.      to intercept it and use it for their own purposes. Instead, use an
  19550.      encrypted protocol such as SSL or SSH. MySQL supports internal SSL
  19551.      connections as of Version 4.0.0.  SSH port-forwarding can be used
  19552.      to create an encrypted (and compressed) tunnel for the
  19553.      communication.
  19554.  
  19555.    * Learn to use the `tcpdump' and `strings' utilities. For most cases,
  19556.      you can check whether MySQL data streams are unencrypted by
  19557.      issuing a command like the following:
  19558.  
  19559.           shell> tcpdump -l -i eth0 -w - src or dst port 3306 | strings
  19560.  
  19561.      (This works under Linux and should work with small modifications
  19562.      under other systems.)  Warning: If you do not see plaintext data,
  19563.      this doesn't always mean that the information actually is
  19564.      encrypted. If you need high security, you should consult with a
  19565.      security expert.
  19566.  
  19567. Making MySQL Secure Against Attackers
  19568. -------------------------------------
  19569.  
  19570. When you connect to a MySQL server, you should use a password.  The
  19571. password is not transmitted in clear text over the connection. Password
  19572. handling during the client connection sequence was upgraded in MySQL
  19573. 4.1.1 to be very secure.  If you are using an older version of MySQL,
  19574. or are still using pre-4.1.1-style passwords, the encryption algorithm
  19575. is less strong and with some effort a clever attacker who can sniff the
  19576. traffic between the client and the server can crack the password.  (See
  19577. *Note Password hashing:: for a discussion of the different password
  19578. handling methods.)  If the connection between the client and the server
  19579. goes through an untrusted network, you should use an SSH tunnel to
  19580. encrypt the communication.
  19581.  
  19582. All other information is transferred as text that can be read by anyone
  19583. who is able to watch the connection.  If you are concerned about this,
  19584. you can use the compressed protocol (in MySQL 3.22 and above) to make
  19585. traffic much more difficult to decipher.  To make the connection even
  19586. more secure, you should use SSH to get an encrypted TCP/IP connection
  19587. between a MySQL server and a MySQL client.  You can find an Open Source
  19588. SSH client at `http://www.openssh.org/', and a commercial SSH client at
  19589. `http://www.ssh.com/'.
  19590.  
  19591. If you are using MySQL 4.0 or newer, you can also use internal OpenSSL
  19592. support.  *Note Secure connections::.
  19593.  
  19594. To make a MySQL system secure, you should strongly consider the
  19595. following suggestions:
  19596.  
  19597.    * Use passwords for all MySQL users. A client program does not
  19598.      necessarily know the identity of the person running it. It is
  19599.      common for client/server applications that the user can specify
  19600.      any username to the client program.  For example, anyone can use
  19601.      the `mysql' program to connect as any other person simply by
  19602.      invoking it as `mysql -u OTHER_USER DB_NAME' if OTHER_USER has no
  19603.      password. If all users have a password, connecting using another
  19604.      user's account becomes much more difficult.
  19605.  
  19606.      To change the password for a user, use the `SET PASSWORD'
  19607.      statement.  It is also possible to update the `user' table in the
  19608.      `mysql' database directly.  For example, to change the password of
  19609.      all MySQL accounts that have a username of `root', do this:
  19610.  
  19611.           shell> mysql -u root
  19612.           mysql> UPDATE mysql.user SET Password=PASSWORD('NEWPWD')
  19613.               -> WHERE User='root';
  19614.           mysql> FLUSH PRIVILEGES;
  19615.  
  19616.    * Don't run the MySQL server as the Unix `root' user.  This is very
  19617.      dangerous, because any user with the `FILE' privilege will be able
  19618.      to create files as `root' (for example, `~root/.bashrc'). To
  19619.      prevent this, `mysqld' refuses to run as `root' unless that is
  19620.      specified explicitly using a `--user=root' option.
  19621.  
  19622.      `mysqld' can be run as an ordinary unprivileged user instead.  You
  19623.      can also create a separate Unix account named `mysql' to make
  19624.      everything even more secure. Use the account only for
  19625.      administering MySQL.  To start `mysqld' as another Unix user, add
  19626.      a `user' option that specifies the username to the `[mysqld]'
  19627.      group of the `/etc/my.cnf' option file or the `my.cnf' option file
  19628.      in the server's data directory. For example:
  19629.  
  19630.           [mysqld]
  19631.           user=mysql
  19632.  
  19633.      This causes the server to start as the designated user whether you
  19634.      start it manually or by using `mysqld_safe' or `mysql.server'.
  19635.      For more details, see *Note Changing MySQL user::.
  19636.  
  19637.      Running `mysqld' as a Unix user other than `root' does not mean
  19638.      that you need to change the `root' username in the `user' table.
  19639.      Usernames for MySQL accounts have nothing to do with usernames for
  19640.      Unix accounts.
  19641.  
  19642.    * Don't allow the use of symlinks to tables. (This can be disabled
  19643.      with the `--skip-symbolic-links' option.) This is especially
  19644.      important if you run `mysqld' as `root', because anyone that has
  19645.      write access to the server's data directory then could delete any
  19646.      file in the system!  *Note Symbolic links to tables::.
  19647.  
  19648.    * Make sure that the only Unix user with read or write privileges in
  19649.      the database directories is the user that `mysqld' runs as.
  19650.  
  19651.    * Don't grant the `PROCESS' or `SUPER' privilege to
  19652.      non-administrative users.  The output of `mysqladmin processlist'
  19653.      shows the text of the currently executing queries, so any user who
  19654.      is allowed to execute that command might be able to see if another
  19655.      user issues an `UPDATE user SET password=PASSWORD('not_secure')'
  19656.      query.
  19657.  
  19658.      `mysqld' reserves an extra connection for users who have the
  19659.      `SUPER' privilege (`PROCESS' before MySQL 4.0.2), so that a MySQL
  19660.      `root' user can log in and check server activity even if all normal
  19661.      connections are in use.
  19662.  
  19663.      The `SUPER' privilege can be used to terminate client connections,
  19664.      change server operation by changing the value of system variables,
  19665.      and control replication servers.
  19666.  
  19667.    * Don't grant the `FILE' privilege to non-administrative users.  Any
  19668.      user that has this privilege can write a file anywhere in the
  19669.      filesystem with the privileges of the `mysqld' daemon!  To make
  19670.      this a bit safer, files generated with `SELECT ... INTO OUTFILE'
  19671.      will not overwrite existing files and are writable by everyone.
  19672.  
  19673.      The `FILE' privilege may also be used to read any file that is
  19674.      world-readable or accessible to the Unix user that the server runs
  19675.      as.  With this privilege, you can read any file into a database
  19676.      table.  This could be abused, for example, by using `LOAD DATA' to
  19677.      load `/etc/passwd' into a table, which then can be displayed with
  19678.      `SELECT'.
  19679.  
  19680.    * If you don't trust your DNS, you should use IP numbers rather than
  19681.      hostnames in the grant tables. In any case, you should be very
  19682.      careful about creating grant table entries using hostname values
  19683.      that contain wildcards!
  19684.  
  19685.    * If you want to restrict the number of connections allowed to a
  19686.      single account, you can do so by setting the
  19687.      `max_user_connections' variable in `mysqld'.  The `GRANT'
  19688.      statement also supports resource control options for limiting the
  19689.      extent of server use allowed to an account.
  19690.  
  19691. Startup Options for `mysqld' Concerning Security
  19692. ------------------------------------------------
  19693.  
  19694. The following `mysqld' options affect security:
  19695.  
  19696. `--local-infile[={0|1}]'
  19697.      If you start the server with `--local-infile=0', clients cannot use
  19698.      `LOCAL' in `LOAD DATA' statements.  *Note `LOAD DATA LOCAL': LOAD
  19699.      DATA LOCAL.
  19700.  
  19701. `--safe-show-database'
  19702.      With this option, the `SHOW DATABASES' statement displays the names
  19703.      of only those databases for which the user has some kind of
  19704.      privilege.  As of MySQL 4.0.2, this option is deprecated and
  19705.      doesn't do anything (it is enabled by default), because there is
  19706.      now a `SHOW DATABASES' privilege that can be used to control
  19707.      access to database names on a per-account basis. *Note `GRANT':
  19708.      GRANT.
  19709.  
  19710. `--safe-user-create'
  19711.      If this is enabled, a user cannot create new users with the `GRANT'
  19712.      statement unless the user has the `INSERT' privilege for the
  19713.      `mysql.user' table.  If you want a user to have the ability to
  19714.      create new users with those privileges that the user has right to
  19715.      grant, you should grant the user the following privilege:
  19716.  
  19717.           mysql> GRANT INSERT(user) ON mysql.user TO 'USER_NAME'@'HOST_NAME';
  19718.  
  19719.      This will ensure that the user can't change any privilege columns
  19720.      directly, but has to use the `GRANT' statement to give privileges
  19721.      to other users.
  19722.  
  19723. `--secure-auth'
  19724.      Disallow authentication for accounts that have old (pre-4.1)
  19725.      passwords.  This option is available as of MySQL 4.1.1.
  19726.  
  19727. `--skip-grant-tables'
  19728.      This option causes the server not to use the privilege system at
  19729.      all. This gives everyone _full access_ to all databases!  (You can
  19730.      tell a running server to start using the grant tables again by
  19731.      executing a `mysqladmin flush-privileges' or `mysqladmin reload'
  19732.      command, or by issuing a `FLUSH PRIVILEGES' statement.)
  19733.  
  19734. `--skip-name-resolve'
  19735.      Hostnames are not resolved.  All `Host' column values in the grant
  19736.      tables must be IP numbers or `localhost'.
  19737.  
  19738. `--skip-networking'
  19739.      Don't allow TCP/IP connections over the network.  All connections
  19740.      to `mysqld' must be made via Unix socket files.  This option is
  19741.      unsuitable when using a MySQL version prior to 3.23.27 with the
  19742.      MIT-pthreads package, because Unix socket files were not supported
  19743.      by MIT-pthreads at that time.
  19744.  
  19745. `--skip-show-database'
  19746.      With this option, the `SHOW DATABASES' statement is allowed only to
  19747.      users who have the `SHOW DATABASES' privilege, and the statement
  19748.      displays all database names.  Without this option, `SHOW
  19749.      DATABASES' is allowed to all users, but displays each database
  19750.      name only if the user has the `SHOW DATABASES' privilege or some
  19751.      privilege for the database.
  19752.  
  19753. Security Issues with `LOAD DATA LOCAL'
  19754. --------------------------------------
  19755.  
  19756. The `LOAD DATA' statement can load a file that is located on the server
  19757. host, or it can load a file that is located on the client host when the
  19758. `LOCAL' keyword is specified.
  19759.  
  19760. There are two potential security issues with supporting the `LOCAL'
  19761. version of `LOAD DATA' statements:
  19762.  
  19763.    * The transfer of the file from the client host to the server host
  19764.      is initiated by the MySQL server. In theory, a patched server
  19765.      could be built that would tell the client program to transfer a
  19766.      file of the server's choosing rather than the file named by the
  19767.      client in the `LOAD DATA' statement. Such a server could access
  19768.      any file on the client host to which the client user has read
  19769.      access.
  19770.  
  19771.    * In a Web environment where the clients are connecting from a Web
  19772.      server, a user could use `LOAD DATA LOCAL' to read any files that
  19773.      the Web server process has read access to (assuming that a user
  19774.      could run any command against the SQL server). In this
  19775.      environment, the client with respect to the MySQL server actually
  19776.      is the Web server, not the program being run by the user
  19777.      connecting to the Web server.
  19778.  
  19779.  
  19780. To deal with these problems, we changed how `LOAD DATA LOCAL' is
  19781. handled as of MySQL 3.23.49 and MySQL 4.0.2 (4.0.13 on Windows):
  19782.  
  19783.    * By default, all MySQL clients and libraries in binary
  19784.      distributions are compiled with the `--enable-local-infile'
  19785.      option, to be compatible with MySQL 3.23.48 and before.
  19786.  
  19787.    * If you build MySQL from source but don't use the
  19788.      `--enable-local-infile' option to `configure', `LOAD DATA LOCAL'
  19789.      cannot be used by any client unless it is written explicitly to
  19790.      invoke `mysql_options(... MYSQL_OPT_LOCAL_INFILE, 0)'.  *Note
  19791.      `mysql_options()': mysql_options.
  19792.  
  19793.    * You can disable all `LOAD DATA LOCAL' commands from the server side
  19794.      by starting `mysqld' with the `--local-infile=0' option.
  19795.  
  19796.    * For the `mysql' command-line client, `LOAD DATA LOCAL' can be
  19797.      enabled by specifying the `--local-infile[=1]' option, or disabled
  19798.      with the `--local-infile=0' option.  Similarly, for `mysqlimport',
  19799.      the `--local' or `-L' option enables local data file loading. In
  19800.      any case, successful use of a local loading operation requires
  19801.      that the server is enabled to allow it.
  19802.  
  19803.    * If you use `LOAD DATA LOCAL' in Perl scripts or other programs that
  19804.      read the `[client]' group from option files, you can add the
  19805.      `local-infile=1' option to that group. However, to keep this from
  19806.      causing problems for programs that do not understand
  19807.      `local-infile', specify it using the `loose-' prefix:
  19808.  
  19809.           [client]
  19810.           loose-local-infile=1
  19811.  
  19812.      The `loose-' prefix can be used as of MySQL 4.0.2.
  19813.  
  19814.    * If `LOAD DATA LOCAL INFILE' is disabled, either in the server or
  19815.      the client, a client that attempts to issue such a statement
  19816.      receives the following error message:
  19817.  
  19818.           ERROR 1148: The used command is not allowed with this MySQL version
  19819.  
  19820.  
  19821. The MySQL Access Privilege System
  19822. =================================
  19823.  
  19824. MySQL has an advanced but non-standard security/privilege system.  This
  19825. section describes how it works.
  19826.  
  19827. What the Privilege System Does
  19828. ------------------------------
  19829.  
  19830. The primary function of the MySQL privilege system is to authenticate a
  19831. user connecting from a given host, and to associate that user with
  19832. privileges on a database such as `SELECT', `INSERT', `UPDATE', and
  19833. `DELETE'.
  19834.  
  19835. Additional functionality includes the ability to have an anonymous user
  19836. and to grant privileges for MySQL-specific functions such as `LOAD DATA
  19837. INFILE' and administrative operations.
  19838.  
  19839. How the Privilege System Works
  19840. ------------------------------
  19841.  
  19842. The MySQL privilege system ensures that all users may perform only the
  19843. operations allowed to them.  As a user, when you connect to a MySQL
  19844. server, your identity is determined by _the host from which you
  19845. connect_ and _the username you specify_.  The system grants privileges
  19846. according to your identity and _what you want to do_.
  19847.  
  19848. MySQL considers both your hostname and username in identifying you
  19849. because there is little reason to assume that a given username belongs
  19850. to the same person everywhere on the Internet.  For example, the user
  19851. `joe' who connects from `office.com' need not be the same person as the
  19852. user `joe' who connects from `elsewhere.com'.  MySQL handles this by
  19853. allowing you to distinguish users on different hosts that happen to
  19854. have the same name:  You can grant `joe' one set of privileges for
  19855. connections from `office.com', and a different set of privileges for
  19856. connections from `elsewhere.com'.
  19857.  
  19858. MySQL access control involves two stages:
  19859.  
  19860.    * Stage 1: The server checks whether you are even allowed to connect.
  19861.  
  19862.    * Stage 2: Assuming that you can connect, the server checks each
  19863.      statement you issue to see whether you have sufficient privileges
  19864.      to perform it.  For example, if you try to select rows from a
  19865.      table in a database or drop a table from the database, the server
  19866.      verifies that you have the `SELECT' privilege for the table or the
  19867.      `DROP' privilege for the database.
  19868.  
  19869. If your privileges are changed (either by yourself or someone else)
  19870. while you are connected, those changes will not necessarily take effect
  19871. immediately for the next statement you issue.  See *Note Privilege
  19872. changes:: for details.
  19873.  
  19874. The server stores privilege information in the grant tables of the
  19875. `mysql' database (that is, in the database named `mysql').  The MySQL
  19876. server reads the contents of these tables into memory when it starts
  19877. and re-reads them under the circumstances indicated in *Note Privilege
  19878. changes::. Access-control decisions are based on the in-memory copies
  19879. of the grant tables.
  19880.  
  19881. Normally, you manipulate the contents of the grant tables indirectly by
  19882. using the `GRANT' and `REVOKE' statements to set up accounts and control
  19883. the privileges available to each one.  *Note `GRANT': GRANT.  The
  19884. discussion here describes the underlying structure of the grant tables
  19885. and how the server uses their contents when interacting with clients.
  19886.  
  19887. The server uses the `user', `db', and `host' tables in the `mysql'
  19888. database at both stages of access control.  The columns in these grant
  19889. tables are shown here:
  19890.  
  19891. *Table Name*   *user*         *db*           *host*
  19892. *Scope         `Host'         `Host'         `Host'
  19893. columns*                                     
  19894.                `User'         `Db'           `Db'
  19895.                `Password'     `User'         
  19896. *Privilege     `Select_priv'  `Select_priv'  `Select_priv'
  19897. columns*                                     
  19898.                `Insert_priv'  `Insert_priv'  `Insert_priv'
  19899.                `Update_priv'  `Update_priv'  `Update_priv'
  19900.                `Delete_priv'  `Delete_priv'  `Delete_priv'
  19901.                `Index_priv'   `Index_priv'   `Index_priv'
  19902.                `Alter_priv'   `Alter_priv'   `Alter_priv'
  19903.                `Create_priv'  `Create_priv'  `Create_priv'
  19904.                `Drop_priv'    `Drop_priv'    `Drop_priv'
  19905.                `Grant_priv'   `Grant_priv'   `Grant_priv'
  19906.                `Create_view_priv'`Create_view_priv'`Create_view_priv'
  19907.                `Show_view_priv'`Show_view_priv'`Show_view_priv'
  19908.                `References_priv'`References_priv'`References_priv'
  19909.                `Reload_priv'                 
  19910.                `Shutdown_priv'               
  19911.                `Process_priv'                
  19912.                `File_priv'                   
  19913.                `Show_db_priv'                
  19914.                `Super_priv'                  
  19915.                `Create_tmp_table_priv'`Create_tmp_table_priv'`Create_tmp_table_priv'
  19916.                `Lock_tables_priv'`Lock_tables_priv'`Lock_tables_priv'
  19917.                `Execute_priv'                
  19918.                `Repl_slave_priv'               
  19919.                `Repl_client_priv'               
  19920.                `ssl_type'                    
  19921.                `ssl_cipher'                  
  19922.                `x509_issuer'                 
  19923.                `x509_subject'                
  19924.                `max_questions'               
  19925.                `max_updates'                 
  19926.                `max_connections'               
  19927.  
  19928. The `ssl_type', `ssl_cipher', `x509_issuer', and `x509_subject' columns
  19929. were added in MySQL 4.0.0.
  19930.  
  19931. The `Create_tmp_table_priv', `Execute_priv', `Lock_tables_priv',
  19932. `Repl_client_priv', `Repl_slave_priv', `Show_db_priv', `Super_priv',
  19933. `max_questions', `max_updates', and `max_connections' columns were
  19934. added in MySQL 4.0.2.
  19935.  
  19936. The `Create_view_priv' and `Show_view_priv' columns were added in MySQL
  19937. 5.0.1.
  19938.  
  19939. During the second stage of access control (request verification), the
  19940. server may, if the request involves tables, additionally consult the
  19941. `tables_priv' and `columns_priv' tables that provide finer control at
  19942. the table and column levels.  The columns in these tables are shown
  19943. here:
  19944.  
  19945. *Table Name*   *tables_priv*  *columns_priv*
  19946. *Scope         `Host'         `Host'
  19947. columns*                      
  19948.                `Db'           `Db'
  19949.                `User'         `User'
  19950.                `Table_name'   `Table_name'
  19951.                               `Column_name'
  19952. *Privilege     `Table_priv'   `Column_priv'
  19953. columns*                      
  19954.                `Column_priv'  
  19955. *Other         `Timestamp'    `Timestamp'
  19956. columns*                      
  19957.                `Grantor'      
  19958.  
  19959. The `Timestamp' and `Grantor' columns currently are unused and are
  19960. discussed no further here.
  19961.  
  19962. Each grant table contains scope columns and privilege columns:
  19963.  
  19964.    * Scope columns determine the scope of each entry (row) in the
  19965.      tables; that is, the context in which the entry applies.  For
  19966.      example, a `user' table entry with `Host' and `User' values of
  19967.      `'thomas.loc.gov'' and `'bob'' would be used for authenticating
  19968.      connections made to the server from the host `thomas.loc.gov' by a
  19969.      client that specifies a username of `bob'.  Similarly, a `db'
  19970.      table entry with `Host', `User', and `Db' column values of
  19971.      `'thomas.loc.gov'', `'bob'' and `'reports'' would be used when
  19972.      `bob' connects from the host `thomas.loc.gov' to access the
  19973.      `reports' database.  The `tables_priv' and `columns_priv' tables
  19974.      contain scope columns indicating tables or table/column
  19975.      combinations to which each entry applies.
  19976.  
  19977.    * Privilege columns indicate the privileges granted by a table
  19978.      entry; that is, what operations can be performed.  The server
  19979.      combines the information in the various grant tables to form a
  19980.      complete description of a user's privileges.  The rules used to do
  19981.      this are described in *Note Request access::.
  19982.  
  19983.  
  19984. Scope columns contain strings. They are declared as shown here; the
  19985. default value for each is the empty string:
  19986.  
  19987. *Column Name*  *Type*
  19988. `Host'         `CHAR(60)'
  19989. `User'         `CHAR(16)'
  19990. `Password'     `CHAR(16)'
  19991. `Db'           `CHAR(64)'
  19992. `Table_name'   `CHAR(60)'
  19993. `Column_name'  `CHAR(60)'
  19994.  
  19995. Before MySQL 3.23, the `Db' column is `CHAR(32)' in some tables and
  19996. `CHAR(60)' in others.
  19997.  
  19998. For access-checking purposes, comparisons of `Host' values are
  19999. case-insensitive.  `User', `Password', `Db', and `Table_name' values
  20000. are case sensitive.  `Column_name' values are case insensitive in MySQL
  20001. 3.22.12 or later.
  20002.  
  20003. In the `user', `db', and `host' tables, each privilege is listed in a
  20004. separate column that is declared as `ENUM('N','Y') DEFAULT 'N''. In
  20005. other words, each privilege can disabled or enabled, with the default
  20006. being disabled.
  20007.  
  20008. In the `tables_priv' and `columns_priv' tables, the privilege columns
  20009. are declared as `SET' columns. Values in these columns can contain any
  20010. combination of the privileges controlled by the table:
  20011.  
  20012. *Table      *Column     *Possible Set Elements*
  20013. Name*       Name*       
  20014. `tables_priv'`Table_priv'`'Select', 'Insert', 'Update',
  20015.                         'Delete', 'Create', 'Drop', 'Grant',
  20016.                         'References', 'Index', 'Alter''
  20017. `tables_priv'`Column_priv'`'Select', 'Insert', 'Update',
  20018.                         'References''
  20019. `columns_priv'`Column_priv'`'Select', 'Insert', 'Update',
  20020.                         'References''
  20021.  
  20022. Briefly, the server uses the grant tables as follows:
  20023.  
  20024.    * The `user' table scope columns determine whether to reject or allow
  20025.      incoming connections.  For allowed connections, any privileges
  20026.      granted in the `user' table indicate the user's global (superuser)
  20027.      privileges.  These privileges apply to _all_ databases on the
  20028.      server.
  20029.  
  20030.    * The `db' table scope columns determine which users can access which
  20031.      databases from which hosts.  The privilege columns determine which
  20032.      operations are allowed. A privilege granted at the database level
  20033.      applies to the database and to all its tables.
  20034.  
  20035.    * The `host' table is used in conjunction with the `db' table when
  20036.      you want a given `db' table entry to apply to several hosts.  For
  20037.      example, if you want a user to be able to use a database from
  20038.      several hosts in your network, leave the `Host' value empty in the
  20039.      user's `db' table entry, then populate the `host' table with an
  20040.      entry for each of those hosts.  This mechanism is described more
  20041.      detail in *Note Request access::.
  20042.  
  20043.      *Note*: The `host' table is not affected by the `GRANT' and
  20044.      `REVOKE' statements. Most MySQL installations need not use this
  20045.      table at all.
  20046.  
  20047.    * The `tables_priv' and `columns_priv' tables are similar to the
  20048.      `db' table, but are more fine-grained: They apply at the table and
  20049.      column levels rather than at the database level.  A privilege
  20050.      granted at the table level applies to the table and to all its
  20051.      columns.  A privilege granted at the column level applies only to
  20052.      a specific column.
  20053.  
  20054. Administrative privileges (such as `RELOAD' or `SHUTDOWN') are
  20055. specified only in the `user' table.  This is because administrative
  20056. operations are operations on the server itself and are not
  20057. database-specific, so there is no reason to list these privileges in the
  20058. other grant tables.  In fact, to determine whether you can perform an
  20059. administrative operation, the server need consult only the `user' table.
  20060.  
  20061. The `FILE' privilege also is specified only in the `user' table.  It is
  20062. not an administrative privilege as such, but your ability to read or
  20063. write files on the server host is independent of the database you are
  20064. accessing.
  20065.  
  20066. The `mysqld' server reads the contents of the grant tables into memory
  20067. when it starts. You can tell it to re-read the tables by issuing a
  20068. `FLUSH PRIVILEGES' statement or executing a `mysqladmin
  20069. flush-privileges' or `mysqladmin reload' command.  Changes to the grant
  20070. tables take effect as indicated in *Note Privilege changes::.
  20071.  
  20072. When you modify the contents of the grant tables, it is a good idea to
  20073. make sure that your changes set up privileges the way you want. One way
  20074. to check the privileges for a given account is to use the `SHOW GRANTS'
  20075. statement.  For example, to determine the privileges that are granted
  20076. to an account with `Host' and `User' values of `pc84.example.com' and
  20077. `bob', issue this statement:
  20078.  
  20079.      mysql> SHOW GRANTS FOR 'bob'@'pc84.example.com';
  20080.  
  20081. A useful diagnostic tool is the `mysqlaccess' script, which Yves
  20082. Carlier has provided for the MySQL distribution.  Invoke `mysqlaccess'
  20083. with the `--help' option to find out how it works.  Note that
  20084. `mysqlaccess' checks access using only the `user', `db', and `host'
  20085. tables.  It does not check table or column privileges specified in the
  20086. `tables_priv' or `columns_priv' tables.
  20087.  
  20088. For additional help in diagnosing privilege-related problems, see *Note
  20089. Access denied::.  For general advice on security issues, see *Note
  20090. Security::.
  20091.  
  20092. Privileges Provided by MySQL
  20093. ----------------------------
  20094.  
  20095. Information about account privileges is stored in the `user', `db',
  20096. `host', `tables_priv', and `columns_priv' tables in the `mysql'
  20097. database.  The MySQL server reads the contents of these tables into
  20098. memory when it starts and re-reads them under the circumstances
  20099. indicated in *Note Privilege changes::.  Access-control decisions are
  20100. based on the in-memory copies of the grant tables.
  20101.  
  20102. The names used in this manual to refer to the privileges provided by
  20103. MySQL are shown in the following table, along with the table column name
  20104. associated with each privilege in the grant tables and the context in
  20105. which the privilege applies. Further information about the meaning of
  20106. each privilege may be found at *Note `GRANT': GRANT.
  20107.  
  20108. *Privilege* *Column*       *Context*
  20109. `ALTER'     `Alter_priv'   tables
  20110. `DELETE'    `Delete_priv'  tables
  20111. `INDEX'     `Index_priv'   tables
  20112. `INSERT'    `Insert_priv'  tables
  20113. `SELECT'    `Select_priv'  tables
  20114. `UPDATE'    `Update_priv'  tables
  20115. `CREATE'    `Create_priv'  databases, tables, or
  20116.                            indexes
  20117. `DROP'      `Drop_priv'    databases or tables
  20118. `GRANT'     `Grant_priv'   databases or tables
  20119. `REFERENCES'`References_priv'databases or tables
  20120. `CREATE     `Create_tmp_table_priv'server administration
  20121. TEMPORARY                  
  20122. TABLES'                    
  20123. `EXECUTE'   `Execute_priv' server administration
  20124. `FILE'      `File_priv'    file access on server
  20125.                            host
  20126. `LOCK       `Lock_tables_priv'server administration
  20127. TABLES'                    
  20128. `PROCESS'   `Process_priv' server administration
  20129. `RELOAD'    `Reload_priv'  server administration
  20130. `REPLICATION`Repl_client_priv'server administration
  20131. CLIENT'                    
  20132. `REPLICATION`Repl_slave_priv'server administration
  20133. SLAVE'                     
  20134. `SHOW       `Show_db_priv' server administration
  20135. DATABASES'                 
  20136. `SHUTDOWN'  `Shutdown_priv'server administration
  20137. `SUPER'     `Super_priv'   server administration
  20138.  
  20139. The `CREATE TEMPORARY TABLES', `EXECUTE', `LOCK TABLES', `REPLICATION
  20140. CLIENT', `REPLICATION SLAVE', `SHOW DATABASES', and `SUPER' privileges
  20141. were added in MySQL 4.0.2.
  20142.  
  20143. The `EXECUTE' and `REFERENCES' privileges currently are unused.
  20144.  
  20145. The `SELECT', `INSERT', `UPDATE', and `DELETE' privileges allow you to
  20146. perform operations on rows in existing tables in a database.
  20147.  
  20148. `SELECT' statements require the `SELECT' privilege only if they
  20149. actually retrieve rows from a table.  Some `SELECT' statements do not
  20150. access tables and can be executed without permission for any database.
  20151. For example, you can use the `mysql' client as a simple calculator to
  20152. evaluate expressions that make no reference to tables:
  20153.  
  20154.      mysql> SELECT 1+1;
  20155.      mysql> SELECT PI()*2;
  20156.  
  20157. The `CREATE' and `DROP' privileges allow you to create new databases
  20158. and tables, or to drop (remove) existing databases and tables.  If you
  20159. grant the `DROP' privilege for the `mysql' database to a user, that
  20160. user can drop the database in which the MySQL access privileges are
  20161. stored!
  20162.  
  20163. The `INDEX' privilege allows you to create or drop (remove) indexes.
  20164. `INDEX' applies to existing tables.  If you have the `CREATE' privilege
  20165. for a table, you can include index definitions in the `CREATE TABLE'
  20166. statement.
  20167.  
  20168. The `ALTER' privilege allows you to use `ALTER TABLE' to change the
  20169. structure of or rename tables.
  20170.  
  20171. The `GRANT' privilege allows you to give to other users those
  20172. privileges that you yourself possess.
  20173.  
  20174. The `FILE' privilege gives you permission to read and write files on
  20175. the server host using the `LOAD DATA INFILE' and `SELECT ... INTO
  20176. OUTFILE' statements. A user who has the `FILE' privilege can read any
  20177. file on the server host that is either world-readable or readable by
  20178. the MySQL server. (This implies the user can read any file in any
  20179. database directory, because the server can access any of those files.)
  20180. The `FILE' privilege also allows the user to create new files in any
  20181. directory where the MySQL server has write access. Existing files
  20182. cannot be overwritten.
  20183.  
  20184. The remaining privileges are used for administrative operations. Many of
  20185. them can be performed by using the `mysqladmin' program or by issuing
  20186. SQL statements.  The following table shows which `mysqladmin' commands
  20187. each administrative privilege allows you to execute:
  20188.  
  20189. *Privilege* *Commands Permitted to Privilege Holders*
  20190. `RELOAD'    `flush-hosts', `flush-logs', `flush-privileges',
  20191.             `flush-status', `flush-tables', `flush-threads',
  20192.             `refresh', `reload'
  20193. `SHUTDOWN'  `shutdown'
  20194. `PROCESS'   `processlist'
  20195. `SUPER'     `kill'
  20196.  
  20197. The `reload' command tells the server to re-read the grant tables into
  20198. memory.  `flush-privileges' is a synonym for `reload'.  The `refresh'
  20199. command closes and reopens the log files and flushes all tables.  The
  20200. other `flush-XXX' commands perform functions similar to `refresh', but
  20201. are more specific and may be preferable in some instances.  For
  20202. example, if you want to flush just the log files, `flush-logs' is a
  20203. better choice than `refresh'.
  20204.  
  20205. The `shutdown' command shuts down the server. This command can be issued
  20206. only from `mysqladmin'. There is no corresponding SQL statement.
  20207.  
  20208. The `processlist' command displays information about the threads
  20209. executing within the server (that is, about the statements being
  20210. executed by clients associated with other accounts).  The `kill'
  20211. command terminates server threads.  You can always display or kill your
  20212. own threads, but you need the `PROCESS' privilege to display threads
  20213. initiated by other users and the `SUPER' privilege to kill them.  *Note
  20214. `KILL': KILL. Prior to MySQL 4.0.2 when `SUPER' was introduced, the
  20215. `PROCESS' privilege controls the ability to both see and terminate
  20216. threads for other clients.
  20217.  
  20218. The `CREATE TEMPORARY TABLES' privilege allows the use of the keyword
  20219. `TEMPORARY' in `CREATE TABLE' statements.
  20220.  
  20221. The `LOCK TABLES' privilege allows the use of explicit `LOCK TABLES'
  20222. statements to lock tables for which you have the `SELECT' privilege.
  20223. This includes the use of write locks, which prevents anyone else from
  20224. reading the locked table.
  20225.  
  20226. The `REPLICATION CLIENT' privilege allows the use of `SHOW MASTER
  20227. STATUS' and `SHOW SLAVE STATUS'.
  20228.  
  20229. The `REPLICATION SLAVE' privilege should be granted to accounts that are
  20230. used by slave servers when they connect to the current server as their
  20231. master.  Without this privilege, the slave cannot request updates that
  20232. have been made to databases on the master server.
  20233.  
  20234. The `SHOW DATABASES' privilege allows the account to see database names
  20235. by issuing the `SHOW DATABASE' statement. Accounts that do not have this
  20236. privilege see only databases for which they have some privileges, and
  20237. cannot use the statement at all if the server was started with the
  20238. `--skip-show-database' option.
  20239.  
  20240. It is a good idea in general to grant privileges to only those accounts
  20241. that need them, but you should exercise particular caution in granting
  20242. administrative privileges:
  20243.  
  20244.    * The `GRANT' privilege allows users to give their privileges to
  20245.      other users.  Two users with different privileges and with the
  20246.      `GRANT' privilege are able to combine privileges.
  20247.  
  20248.    * The `ALTER' privilege may be used to subvert the privilege system
  20249.      by renaming tables.
  20250.  
  20251.    * The `FILE' privilege can be abused to read into a database table
  20252.      any files that the MySQL server can read on the server host. This
  20253.      includes all world-readable files and files in the server's data
  20254.      directory. The table can then be accessed using `SELECT' to
  20255.      transfer its contents to the client host.
  20256.  
  20257.    * The `SHUTDOWN' privilege can be abused to deny service to other
  20258.      users entirely by terminating the server.
  20259.  
  20260.    * The `PROCESS' privilege can be used to view the plain text of
  20261.      currently executing queries, including queries that set or change
  20262.      passwords.
  20263.  
  20264.    * The `SUPER' privilege can be used to terminate other clients or
  20265.      change how the server operates.
  20266.  
  20267.    * Privileges granted for the `mysql' database itself can be used to
  20268.      change passwords and other access privilege information.
  20269.      Passwords are stored encrypted, so a malicious user cannot simply
  20270.      read them to know the plain text password.  However, a user with
  20271.      write access to the `user' table `Password' column can change an
  20272.      account's password, and then connect to the MySQL server using
  20273.      that account.
  20274.  
  20275.  
  20276. There are some things that you cannot do with the MySQL privilege
  20277. system:
  20278.  
  20279.    * You cannot explicitly specify that a given user should be denied
  20280.      access.  That is, you cannot explicitly match a user and then
  20281.      refuse the connection.
  20282.  
  20283.    * You cannot specify that a user has privileges to create or drop
  20284.      tables in a database but not to create or drop the database itself.
  20285.  
  20286. Connecting to the MySQL Server
  20287. ------------------------------
  20288.  
  20289. MySQL client programs generally expect you to specify connection
  20290. parameters when you want to access a MySQL server:
  20291.  
  20292.    * The name of the host where the MySQL server is running
  20293.  
  20294.    * Your username
  20295.  
  20296.    * Your password
  20297.  
  20298. For example, the `mysql' client can be started as follows from a
  20299. command-line prompt (indicated here by `shell>'):
  20300.  
  20301.      shell> mysql -h HOST_NAME -u USER_NAME -pYOUR_PASS
  20302.  
  20303. Alternate forms of the `-h', `-u', and `-p' options are
  20304. `--host=HOST_NAME', `--user=USER_NAME', and `--password=YOUR_PASS'.
  20305. Note that there is _no space_ between `-p' or `--password=' and the
  20306. password following it.
  20307.  
  20308. If you use a `-p' or `--password' option but do not specify the
  20309. password value, the client program will prompt you to enter the
  20310. password.  The password is not displayed as you enter it.  This is more
  20311. secure than giving the password on the command line.  Any user on your
  20312. system may be able to see a password specified on the command line by
  20313. executing a command such as `ps auxww'.  *Note Password security::.
  20314.  
  20315. MySQL client programs use default values for any connection parameter
  20316. option that you do not specify:
  20317.  
  20318.    * The default hostname is `localhost'.
  20319.  
  20320.    * The default username is `ODBC' on Windows and your Unix login name
  20321.      on Unix.
  20322.  
  20323.    * No password is supplied if `-p' is missing.
  20324.  
  20325. Thus, for a Unix user with a login name of `joe', all of the following
  20326. commands are equivalent:
  20327.  
  20328.      shell> mysql -h localhost -u joe
  20329.      shell> mysql -h localhost
  20330.      shell> mysql -u joe
  20331.      shell> mysql
  20332.  
  20333. Other MySQL clients behave similarly.
  20334.  
  20335. You can specify different default values to be used when you make a
  20336. connection so that you need not enter them on the command line each
  20337. time you invoke a client program.  This can be done in a couple of ways:
  20338.  
  20339.    * You can specify connection parameters in the `[client]' section of
  20340.      an option file.  The relevant section of the file might look like
  20341.      this:
  20342.  
  20343.           [client]
  20344.           host=HOST_NAME
  20345.           user=USER_NAME
  20346.           password=YOUR_PASS
  20347.  
  20348.      Option files are discussed further in *Note Option files::.
  20349.  
  20350.    * You can specify some connection parameters using environment
  20351.      variables.  The host can be specified for `mysql' using
  20352.      `MYSQL_HOST'.  The MySQL username can be specified using `USER'
  20353.      (this is for Windows and NetWare only).  The password can be
  20354.      specified using `MYSQL_PWD', although this is insecure; see *Note
  20355.      Password security::.  For a list of variables, see *Note
  20356.      Environment variables::.
  20357.  
  20358. Access Control, Stage 1: Connection Verification
  20359. ------------------------------------------------
  20360.  
  20361. When you attempt to connect to a MySQL server, the server accepts or
  20362. rejects the connection based on your identity and whether you can
  20363. verify your identity by supplying the correct password.  If not, the
  20364. server denies access to you completely.  Otherwise, the server accepts
  20365. the connection, then enters Stage 2 and waits for requests.
  20366.  
  20367. Your identity is based on two pieces of information:
  20368.  
  20369.    * The client host from which you connect
  20370.  
  20371.    * Your MySQL username
  20372.  
  20373. Identity checking is performed using the three `user' table scope
  20374. columns (`Host', `User', and `Password').  The server accepts the
  20375. connection only if the `Host' and `User' columns in some `user' table
  20376. record match the client hostname and username, and the client supplies
  20377. the password specified in that record.
  20378.  
  20379. `Host' values in the `user' table may be specified as follows:
  20380.  
  20381.    * A `Host' value may be a hostname or an IP number, or `'localhost''
  20382.      to indicate the local host.
  20383.  
  20384.    * You can use the wildcard characters `%' and `_' in `Host' column
  20385.      values.  These have the same meaning as for pattern-matching
  20386.      operations performed with the `LIKE' operator.  For example, a
  20387.      `Host' value of `'%'' matches any hostname, whereas a value of
  20388.      `'%.mysql.com'' matches any host in the `mysql.com' domain.
  20389.  
  20390.    * As of MySQL 3.23, for `Host' values specified as IP numbers, you
  20391.      can specify a netmask indicating how many address bits to use for
  20392.      the network number. For example:
  20393.  
  20394.           mysql> GRANT ALL PRIVILEGES ON db.*
  20395.               -> TO david@'192.58.197.0/255.255.255.0';
  20396.  
  20397.      This allows `david' to connect from any client host having an IP
  20398.      number `client_ip' for which the following condition is true:
  20399.  
  20400.           client_ip & netmask = host_ip
  20401.  
  20402.      That is, for the `GRANT' statement just shown:
  20403.  
  20404.           client_ip & 255.255.255.0 = 192.58.197.0
  20405.  
  20406.      IP numbers that satisfy this condition and can connect to the
  20407.      MySQL server are those that lie in the range from `192.58.197.0' to
  20408.      `192.58.197.255'.
  20409.  
  20410.    * A blank `Host' value in a `db' table record means that its
  20411.      privileges should be combined with those in the entry in the `host'
  20412.      table that matches the client hostname.  The privileges are
  20413.      combined using an AND (intersection) operation, not OR (union).
  20414.      You can find more information about the `host' table in *Note
  20415.      Request access::.
  20416.  
  20417.      A blank `Host' value in the other grant tables is the same as
  20418.      `'%''.
  20419.  
  20420.  
  20421. Because you can use IP wildcard values in the `Host' column (for
  20422. example, `'144.155.166.%'' to match every host on a subnet), someone
  20423. could try to exploit this capability by naming a host
  20424. `144.155.166.somewhere.com'.  To foil such attempts, MySQL disallows
  20425. matching on hostnames that start with digits and a dot. Thus, if you
  20426. have a host named something like `1.2.foo.com', its name will never
  20427. match the `Host' column of the grant tables.  An IP wildcard value can
  20428. match only IP numbers, not hostnames.
  20429.  
  20430. In the `User' column, wildcard characters are not allowed, but you can
  20431. specify a blank value, which matches any name.  If the `user' table
  20432. entry that matches an incoming connection has a blank username, the
  20433. user is considered to be an anonymous user with no name, not a user
  20434. with the name that the client actually specified.  This means that a
  20435. blank username is used for all further access checking for the duration
  20436. of the connection (that is, during Stage 2).
  20437.  
  20438. The `Password' column can be blank.  This is not a wildcard and does
  20439. not mean that any password matches. It means that the user must connect
  20440. without specifying a password.
  20441.  
  20442. Non-blank `Password' values in the `user' table represent encrypted
  20443. passwords.  MySQL does not store passwords in plaintext form for anyone
  20444. to see.  Rather, the password supplied by a user who is attempting to
  20445. connect is encrypted (using the `PASSWORD()' function). The encrypted
  20446. password then is used during the connection process when checking
  20447. whether the password is correct. (This is done without the encrypted
  20448. password ever traveling over the connection.)  From MySQL's point of
  20449. view, the encrypted password is the REAL password, so you should not
  20450. give anyone access to it!  In particular, don't give non-administrative
  20451. users read access to the tables in the `mysql' database!
  20452.  
  20453. From version 4.1 on, MySQL employs a stronger authentication method
  20454. that has better password protection during the connection process than
  20455. in earlier versions. It is secure even if TCP/IP packets are sniffed or
  20456. the `mysql' database is captured.  Password encryption is discussed
  20457. further in *Note Password hashing::.
  20458.  
  20459. The following examples show how various combinations of `Host' and
  20460. `User' values in the `user' table apply to incoming connections:
  20461.  
  20462. `Host' *Value*            `User'      *Connections Matched by Entry*
  20463.                           *Value*     
  20464. `'thomas.loc.gov''        `'fred''    `fred', connecting from
  20465.                                       `thomas.loc.gov'
  20466. `'thomas.loc.gov''        `'''        Any user, connecting from
  20467.                                       `thomas.loc.gov'
  20468. `'%''                     `'fred''    `fred', connecting from any host
  20469. `'%''                     `'''        Any user, connecting from any host
  20470. `'%.loc.gov''             `'fred''    `fred', connecting from any host in
  20471.                                       the `loc.gov' domain
  20472. `'x.y.%''                 `'fred''    `fred', connecting from `x.y.net',
  20473.                                       `x.y.com', `x.y.edu', and so on.
  20474.                                       (this is probably not useful)
  20475. `'144.155.166.177''       `'fred''    `fred', connecting from the host
  20476.                                       with IP address `144.155.166.177'
  20477. `'144.155.166.%''         `'fred''    `fred', connecting from any host in
  20478.                                       the `144.155.166' class C subnet
  20479. `'144.155.166.0/255.255.255.0''`'fred''    Same as previous example
  20480.  
  20481. It is possible for the client hostname and username of an incoming
  20482. connection to match more than one entry in the `user' table.  The
  20483. preceding set of examples demonstrates this: Several of the entries
  20484. shown match a connection from `thomas.loc.gov' by `fred'.
  20485.  
  20486. When multiple matches are possible, the server must determine which of
  20487. them to use.  It resolves this issue as follows:
  20488.  
  20489.    * Whenever the server reads the `user' table into memory, it sorts
  20490.      the entries.
  20491.  
  20492.    * When a client attempts to connect, the server looks through the
  20493.      entries in sorted order.
  20494.  
  20495.    * The server uses the first entry that matches the client hostname
  20496.      and username.
  20497.  
  20498. To see how this works, suppose that the `user' table looks like this:
  20499.  
  20500.      +-----------+----------+-
  20501.      | Host      | User     | ...
  20502.      +-----------+----------+-
  20503.      | %         | root     | ...
  20504.      | %         | jeffrey  | ...
  20505.      | localhost | root     | ...
  20506.      | localhost |          | ...
  20507.      +-----------+----------+-
  20508.  
  20509. When the server reads in the table, it orders the entries with the
  20510. most-specific `Host' values first.  Literal hostnames and IP numbers
  20511. are the most specific. The pattern `'%'' means "any host" and is least
  20512. specific.  Entries with the same `Host' value are ordered with the
  20513. most-specific `User' values first (a blank `User' value means "any
  20514. user" and is least specific). For the `user' table just shown, the
  20515. result after sorting looks like this:
  20516.  
  20517.      +-----------+----------+-
  20518.      | Host      | User     | ...
  20519.      +-----------+----------+-
  20520.      | localhost | root     | ...
  20521.      | localhost |          | ...
  20522.      | %         | jeffrey  | ...
  20523.      | %         | root     | ...
  20524.      +-----------+----------+-
  20525.  
  20526. When a client attempts to connect, the server looks through the sorted
  20527. entries and uses the first match found.  For a connection from
  20528. `localhost' by `jeffrey', two of the entries in the table match: the
  20529. one with `Host' and `User' values of `'localhost'' and `''', and the
  20530. one with values of `'%'' and `'jeffrey''.  The `'localhost'' entry
  20531. appears first in sorted order, so that is the one the server uses.
  20532.  
  20533. Here is another example.  Suppose that the `user' table looks like this:
  20534.  
  20535.      +----------------+----------+-
  20536.      | Host           | User     | ...
  20537.      +----------------+----------+-
  20538.      | %              | jeffrey  | ...
  20539.      | thomas.loc.gov |          | ...
  20540.      +----------------+----------+-
  20541.  
  20542. The sorted table looks like this:
  20543.  
  20544.      +----------------+----------+-
  20545.      | Host           | User     | ...
  20546.      +----------------+----------+-
  20547.      | thomas.loc.gov |          | ...
  20548.      | %              | jeffrey  | ...
  20549.      +----------------+----------+-
  20550.  
  20551. A connection by `jeffrey' from `thomas.loc.gov' is matched by the first
  20552. entry, whereas a connection by `jeffrey' from `whitehouse.gov' is
  20553. matched by the second.
  20554.  
  20555. It is a common misconception to think that, for a given username, all
  20556. entries that explicitly name that user will be used first when the
  20557. server attempts to find a match for the connection.  This is simply not
  20558. true.  The previous example illustrates this, where a connection from
  20559. `thomas.loc.gov' by `jeffrey' is first matched not by the entry
  20560. containing `'jeffrey'' as the `User' column value, but by the entry
  20561. with no username!  As a result, `jeffrey' will be authenticated as an
  20562. anonymous user, even though he specified a username when connecting.
  20563.  
  20564. If you are able to connect to the server, but your privileges are not
  20565. what you expect, you probably are being authenticated as some other
  20566. account.  To find out what account the server used to authenticate you,
  20567. use the `CURRENT_USER()' function. It returns a value in
  20568. `USER_NAME@HOST_NAME' format that indicates the `User' and `Host'
  20569. values from the matching `user' table record.  Suppose that `jeffrey'
  20570. connects and issues the following query:
  20571.  
  20572.      mysql> SELECT CURRENT_USER();
  20573.      +----------------+
  20574.      | CURRENT_USER() |
  20575.      +----------------+
  20576.      | @localhost     |
  20577.      +----------------+
  20578.  
  20579. The result shown here indicates that the matching `user' table entry
  20580. had a blank `User' column value.  In other words, the server is
  20581. treating `jeffrey' as an anonymous user.
  20582.  
  20583. The `CURRENT_USER()' function is available as of MySQL 4.0.6.  *Note
  20584. Information functions::.  Another thing you can do to diagnose
  20585. authentication problems is to print out the `user' table and sort it by
  20586. hand to see where the first match is being made.
  20587.  
  20588. Access Control, Stage 2: Request Verification
  20589. ---------------------------------------------
  20590.  
  20591. Once you establish a connection, the server enters Stage 2 of access
  20592. control.  For each request that comes in on the connection, the server
  20593. determines what operation you want to perform, then checks whether you
  20594. have sufficient privileges to do so.  This is where the privilege
  20595. columns in the grant tables come into play.  These privileges can come
  20596. from any of the `user', `db', `host', `tables_priv', or `columns_priv'
  20597. tables.  (You may find it helpful to refer to *Note Privileges::, which
  20598. lists the columns present in each of the grant tables.)
  20599.  
  20600. The `user' table grants privileges that are assigned to you on a global
  20601. basis and that apply no matter what the current database is.  For
  20602. example, if the `user' table grants you the `DELETE' privilege, you can
  20603. delete rows from any table in any database on the server host!  In
  20604. other words, `user' table privileges are superuser privileges.  It is
  20605. wise to grant privileges in the `user' table only to superusers such as
  20606. database administrators.  For other users, you should leave the
  20607. privileges in the `user' table set to `'N'' and grant privileges at more
  20608. specific levels only. You can grant privileges for particular databases,
  20609. tables, or columns.
  20610.  
  20611. The `db' and `host' tables grant database-specific privileges.  Values
  20612. in the scope columns of these tables can take the following forms:
  20613.  
  20614.    * The wildcard characters `%' and `_' can be used in the `Host' and
  20615.      `Db' columns of either table.  These have the same meaning as for
  20616.      pattern-matching operations performed with the `LIKE' operator.
  20617.      If you want to use either character literally when granting
  20618.      privileges, you must escape it with a backslash.  For example, to
  20619.      include `_' character as part of a database name, specify it as
  20620.      `\_' in the `GRANT' statement.
  20621.  
  20622.    * A `'%'' `Host' value in the `db' table means "any host." A blank
  20623.      `Host' value in the `db' table means "consult the `host' table for
  20624.      further information" (a process that is described later in this
  20625.      section).
  20626.  
  20627.    * A `'%'' or blank `Host' value in the `host' table means "any host."
  20628.  
  20629.    * A `'%'' or blank `Db' value in either table means "any database."
  20630.  
  20631.    * A blank `User' value in either table matches the anonymous user.
  20632.  
  20633. The server reads in and sorts the `db' and `host' tables at the same
  20634. time that it reads the `user' table.  The server sorts the `db' table
  20635. based on the `Host', `Db', and `User' scope columns, and sorts the
  20636. `host' table based on the `Host' and `Db' scope columns.  As with the
  20637. `user' table, sorting puts the most-specific values first and
  20638. least-specific values last, and when the server looks for matching
  20639. entries, it uses the first match that it finds.
  20640.  
  20641. The `tables_priv' and `columns_priv' tables grant table-specific and
  20642. column-specific privileges.  Values in the scope columns of these
  20643. tables can take the following form:
  20644.  
  20645.    * The wildcard characters `%' and `_' can be used in the `Host'
  20646.      column of either table.  These have the same meaning as for
  20647.      pattern-matching operations performed with the `LIKE' operator.
  20648.  
  20649.    * A `'%'' or blank `Host' value in either table means "any host."
  20650.  
  20651.    * The `Db', `Table_name', and `Column_name' columns cannot contain
  20652.      wildcards or be blank in either table.
  20653.  
  20654. The server sorts the `tables_priv' and `columns_priv' tables based on
  20655. the `Host', `Db', and `User' columns.  This is similar to `db' table
  20656. sorting, but simpler because only the `Host' column can contain
  20657. wildcards.
  20658.  
  20659. The request verification process is described here.  (If you are
  20660. familiar with the access-checking source code, you will notice that the
  20661. description here differs slightly from the algorithm used in the code.
  20662. The description is equivalent to what the code actually does; it
  20663. differs only to make the explanation simpler.)
  20664.  
  20665. For requests that require administrative privileges such as `SHUTDOWN'
  20666. or `RELOAD', the server checks only the `user' table entry because that
  20667. is the only table that specifies administrative privileges.  Access is
  20668. granted if the entry allows the requested operation and denied
  20669. otherwise.  For example, if you want to execute `mysqladmin shutdown'
  20670. but your `user' table entry doesn't grant the `SHUTDOWN' privilege to
  20671. you, the server denies access without even checking the `db' or `host'
  20672. tables.  (They contain no `Shutdown_priv' column, so there is no need
  20673. to do so.)
  20674.  
  20675. For database-related requests (`INSERT', `UPDATE', and so on), the
  20676. server first checks the user's global (superuser) privileges by looking
  20677. in the `user' table entry.  If the entry allows the requested operation,
  20678. access is granted.  If the global privileges in the `user' table are
  20679. insufficient, the server determines the user's database-specific
  20680. privileges by checking the `db' and `host' tables:
  20681.  
  20682.   1. The server looks in the `db' table for a match on the `Host',
  20683.      `Db', and `User' columns.  The `Host' and `User' columns are
  20684.      matched to the connecting user's hostname and MySQL username.  The
  20685.      `Db' column is matched to the database that the user wants to
  20686.      access.  If there is no entry for the `Host' and `User', access is
  20687.      denied.
  20688.  
  20689.   2. If there is a matching `db' table entry and its `Host' column is
  20690.      not blank, that entry defines the user's database-specific
  20691.      privileges.
  20692.  
  20693.   3. If the matching `db' table entry's `Host' column is blank, it
  20694.      signifies that the `host' table enumerates which hosts should be
  20695.      allowed access to the database.  In this case, a further lookup is
  20696.      done in the `host' table to find a match on the `Host' and `Db'
  20697.      columns.  If no `host' table entry matches, access is denied.  If
  20698.      there is a match, the user's database-specific privileges are
  20699.      computed as the intersection (_not_ the union!) of the privileges
  20700.      in the `db' and `host' table entries; that is, the privileges that
  20701.      are `'Y'' in both entries.  (This way you can grant general
  20702.      privileges in the `db' table entry and then selectively restrict
  20703.      them on a host-by-host basis using the `host' table entries.)
  20704.  
  20705. After determining the database-specific privileges granted by the `db'
  20706. and `host' table entries, the server adds them to the global privileges
  20707. granted by the `user' table.  If the result allows the requested
  20708. operation, access is granted.  Otherwise, the server successively
  20709. checks the user's table and column privileges in the `tables_priv' and
  20710. `columns_priv' tables, adds those to the user's privileges, and allows
  20711. or denies access based on the result.
  20712.  
  20713. Expressed in boolean terms, the preceding description of how a user's
  20714. privileges are calculated may be summarized like this:
  20715.  
  20716.      global privileges
  20717.      OR (database privileges AND host privileges)
  20718.      OR table privileges
  20719.      OR column privileges
  20720.  
  20721. It may not be apparent why, if the global `user' entry privileges are
  20722. initially found to be insufficient for the requested operation, the
  20723. server adds those privileges to the database, table, and column
  20724. privileges later. The reason is that a request might require more than
  20725. one type of privilege.  For example, if you execute an `INSERT INTO ...
  20726. SELECT' statement, you need both the `INSERT' and the `SELECT'
  20727. privileges.  Your privileges might be such that the `user' table entry
  20728. grants one privilege and the `db' table entry grants the other.  In
  20729. this case, you have the necessary privileges to perform the request,
  20730. but the server cannot tell that from either table by itself; the
  20731. privileges granted by the entries in both tables must be combined.
  20732.  
  20733. The `host' table is not affected by the `GRANT' or `REVOKE' statements,
  20734. so it is unused in most MySQL installations. If you modify it directly,
  20735. you can use it for some specialized purposes, such as to to maintain a
  20736. list of secure servers.  For example, at TcX, the `host' table contains
  20737. a list of all machines on the local network. These are granted all
  20738. privileges.
  20739.  
  20740. You can also use the `host' table to indicate hosts that are _not_
  20741. secure.  Suppose that you have a machine `public.your.domain' that is
  20742. located in a public area that you do not consider secure.  You can
  20743. allow access to all hosts on your network except that machine by using
  20744. `host' table entries like this:
  20745.  
  20746.      +--------------------+----+-
  20747.      | Host               | Db | ...
  20748.      +--------------------+----+-
  20749.      | public.your.domain | %  | ... (all privileges set to 'N')
  20750.      | %.your.domain      | %  | ... (all privileges set to 'Y')
  20751.      +--------------------+----+-
  20752.  
  20753. Naturally, you should always test your entries in the grant tables (for
  20754. example, by using `SHOW GRANTS' or `mysqlaccess') to make sure that
  20755. your access privileges are actually set up the way you think they are.
  20756.  
  20757. When Privilege Changes Take Effect
  20758. ----------------------------------
  20759.  
  20760. When `mysqld' starts, all grant table contents are read into memory and
  20761. become effective for access control at that point.
  20762.  
  20763. When the server reloads the grant tables, privileges for existing
  20764. client connections are affected as follows:
  20765.  
  20766.    * Table and column privilege changes take effect with the client's
  20767.      next request.
  20768.  
  20769.    * Database privilege changes take effect at the next `USE DB_NAME'
  20770.      statement.
  20771.  
  20772.    * Changes to global privileges and passwords take effect the next
  20773.      time the client connects.
  20774.  
  20775. If you modify the grant tables using `GRANT', `REVOKE', or `SET
  20776. PASSWORD', the server notices these changes and reloads the grant
  20777. tables into memory again immediately.
  20778.  
  20779. If you modify the grant tables directly using statements such as
  20780. `INSERT', `UPDATE', or `DELETE', your changes have no effect on
  20781. privilege checking until you either restart the server or tell it to
  20782. reload the tables.  To reload the grant tables manually, issue a `FLUSH
  20783. PRIVILEGES' statement or execute a `mysqladmin flush-privileges' or
  20784. `mysqladmin reload' command.
  20785.  
  20786. If you change the grant tables directly but forget to reload them, your
  20787. changes will have _no effect_ until you restart the server.  This may
  20788. leave you wondering why your changes don't seem to make any difference!
  20789.  
  20790. Causes of `Access denied' Errors
  20791. --------------------------------
  20792.  
  20793. If you encounter problems when you try to connect to the MySQL server,
  20794. the following items describe some courses of action you can take to
  20795. correct the problem.
  20796.  
  20797.    * Make sure that the server is running. If it is not running, you
  20798.      cannot connect to it.  For example, if you attempt to connect to
  20799.      the server and see a message such as one of those following, one
  20800.      cause might be that the server is not running:
  20801.  
  20802.           shell> mysql
  20803.           ERROR 2003: Can't connect to MySQL server on 'HOST_NAME' (111)
  20804.           shell> mysql
  20805.           ERROR 2002: Can't connect to local MySQL server through socket
  20806.           '/tmp/mysql.sock' (111)
  20807.  
  20808.      It might also be that the server is running, but you are trying to
  20809.      connect using a TCP/IP port, named pipe, or Unix socket file
  20810.      different from those on which the server is listening. To correct
  20811.      this when you invoke a client program, specify a `--port' option
  20812.      to indicate the proper port, or a `--socket' option to indicate
  20813.      the proper named pipe or Unix socket file.  To find out what port
  20814.      is used, and where the socket is, you can do:
  20815.  
  20816.           shell> netstat -l | grep mysql
  20817.  
  20818.    * The grant tables must be properly set up so that the server can
  20819.      use them for access control.  For some distribution types (such as
  20820.      binary distributions on Windows on RPM distributions on Linux),
  20821.      the installation process initializes the `mysql' database
  20822.      containing the grant tables.  For distributions that do not do
  20823.      this, you should initialize the grant tables manually by running
  20824.      the `mysql_install_db' script.  For details, see *Note Unix
  20825.      post-installation::.
  20826.  
  20827.      One way to determine whether you need to initialize the grant
  20828.      tables is to look for a `mysql' directory under the data
  20829.      directory. (The data directory normally is named `data' or `var'
  20830.      and is located under your MySQL installation directory.)  Make
  20831.      sure that you have a file named `user.MYD' in the `mysql' database
  20832.      directory.  If you do not, execute the `mysql_install_db' script.
  20833.      After running this script and starting the server, test the
  20834.      initial privileges by executing this command:
  20835.  
  20836.           shell> mysql -u root test
  20837.  
  20838.      The server should let you connect without error.
  20839.  
  20840.    * After a fresh installation, you should connect to the server and
  20841.      set up your users and their access permissions:
  20842.  
  20843.           shell> mysql -u root mysql
  20844.  
  20845.      The server should let you connect because the MySQL `root' user
  20846.      has no password initially.  That is also a security risk, so
  20847.      setting the password for the `root' accounts is something you
  20848.      should do while you're setting up your other MySQL users.  For
  20849.      instructions on setting the initial passwords, see *Note Default
  20850.      privileges::.
  20851.  
  20852.    * If you have updated an existing MySQL installation to a newer
  20853.      version, did you run the `mysql_fix_privilege_tables' script?  If
  20854.      not, do so. The structure of the grant tables changes occasionally
  20855.      when new capabilities are added, so after an upgrade you should
  20856.      always make sure that your tables have the current structure. For
  20857.      instructions, see *Note Upgrading-grant-tables::.
  20858.  
  20859.    * If a client program receives the following error message when it
  20860.      tries to connect, it means that the server expects passwords in a
  20861.      newer format than the client is capable of generating:
  20862.  
  20863.           shell> mysql
  20864.           Client does not support authentication protocol requested
  20865.           by server; consider upgrading MySQL client
  20866.  
  20867.      For information on how to deal with this, see *Note Password
  20868.      hashing:: and *Note Old client::.
  20869.  
  20870.    * If you try to connect as `root' and get the following error, it
  20871.      means that you don't have an entry in the `user' table with a
  20872.      `User' column value of `'root'' and that `mysqld' cannot resolve
  20873.      the hostname for your client:
  20874.  
  20875.           Access denied for user ''@'unknown' to database mysql
  20876.  
  20877.      In this case, you must restart the server with the
  20878.      `--skip-grant-tables' option and edit your `/etc/hosts' or
  20879.      `\windows\hosts' file to add an entry for your host.
  20880.  
  20881.    * Remember that client programs will use connection parameters
  20882.      specified in option files or environment variables.  If a client
  20883.      program seems to be sending incorrect default connection
  20884.      parameters when you don't specify them on the command line, check
  20885.      your environment and any applicable option files. For example, if
  20886.      you get `Access denied' when you run a client without any options,
  20887.      make sure that you haven't specified an old password in any of
  20888.      your option files!
  20889.  
  20890.      You can suppress the use of option files by a client program by
  20891.      invoking it with the `--no-defaults' option. For example:
  20892.  
  20893.           shell> mysqladmin --no-defaults -u root version
  20894.  
  20895.      The option files that clients use are listed in *Note Option
  20896.      files::.  Environment variables are listed in *Note Environment
  20897.      variables::.
  20898.  
  20899.    * If you get the following error, it means that you are using an
  20900.      incorrect `root' password:
  20901.  
  20902.           shell> mysqladmin -u root -pXXXX ver
  20903.           Access denied for user 'root'@'localhost' (using password: YES)
  20904.  
  20905.      If the preceding error occurs even when you haven't specified a
  20906.      password, it means that you have an incorrect password listed in
  20907.      some option file. Try the `--no-defaults' option as described in
  20908.      the previous item.
  20909.  
  20910.      For information on changing passwords, see *Note Passwords::.
  20911.  
  20912.      If you have lost or forgotten the `root' password, you can restart
  20913.      `mysqld' with `--skip-grant-tables' to change the password.  *Note
  20914.      Resetting permissions::.
  20915.  
  20916.    * If you change a password by using `SET PASSWORD', `INSERT', or
  20917.      `UPDATE', you must encrypt the password using the `PASSWORD()'
  20918.      function.  If you do not use `PASSWORD()' for these statements,
  20919.      the password will not work. For example, the following statement
  20920.      sets a password, but fails to encrypt it, so the user will not be
  20921.      able to connect afterward:
  20922.  
  20923.           mysql> SET PASSWORD FOR 'abe'@'HOST_NAME' = 'eagle';
  20924.  
  20925.      Instead, set the password like this:
  20926.  
  20927.           mysql> SET PASSWORD FOR 'abe'@'HOST_NAME' = PASSWORD('eagle');
  20928.  
  20929.      The `PASSWORD()' function is unnecessary when you specify a
  20930.      password using the `GRANT' statement or the `mysqladmin password'
  20931.      command, both of which automatically use `PASSWORD()' to encrypt
  20932.      the password.  *Note Passwords::.
  20933.  
  20934.    * `localhost' is a synonym for your local hostname, and is also the
  20935.      default host to which clients try to connect if you specify no host
  20936.      explicitly.  However, connections to `localhost' on Unix systems
  20937.      do not work if you are using a MySQL version older than 3.23.27
  20938.      that uses MIT-pthreads: `localhost' connections are made using
  20939.      Unix socket files, which were not supported by MIT-pthreads at
  20940.      that time.
  20941.  
  20942.      To avoid this problem on such systems, you can use a
  20943.      `--host=127.0.0.1' option to name the server host explicitly.
  20944.      This will make a TCP/IP connection to the local `mysqld' server.
  20945.      You can also use TCP/IP by specifying a `--host' option that uses
  20946.      the actual hostname of the local host.  In this case, the hostname
  20947.      must be specified in a `user' table entry on the server host, even
  20948.      though you are running the client program on the same host as the
  20949.      server.
  20950.  
  20951.    * If you get an `Access denied' error when trying to connect to the
  20952.      database with `mysql -u user_name', you may have a problem with
  20953.      the `user' table. Check this by executing `mysql -u root mysql'
  20954.      and issuing this SQL statement:
  20955.  
  20956.           mysql> SELECT * FROM user;
  20957.  
  20958.      The result should include an entry with the `Host' and `User'
  20959.      columns matching your computer's hostname and your MySQL username.
  20960.  
  20961.    * The `Access denied' error message will tell you who you are trying
  20962.      to log in as, the client host from which you are trying to
  20963.      connect, and whether or not you were using a password. Normally,
  20964.      you should have one entry in the `user' table that exactly matches
  20965.      the hostname and username that were given in the error message.
  20966.      For example, if you get an error message that contains `using
  20967.      password: NO', it means that you tried to log in without an
  20968.      password.
  20969.  
  20970.    * If the following error occurs when you try to connect from a host
  20971.      other than the one on which the MySQL server is running, it means
  20972.      that there is no row in the `user' table with a `Host' value that
  20973.      matches the client host:
  20974.  
  20975.           Host ... is not allowed to connect to this MySQL server
  20976.  
  20977.      You can fix this by setting up an account for the combination of
  20978.      client hostname and username that you are using when trying to
  20979.      connect.
  20980.  
  20981.      If you don't know the IP number or hostname of the machine from
  20982.      which you are connecting, you should put an entry with `'%'' as
  20983.      the `Host' column value in the `user' table and restart `mysqld'
  20984.      with the `--log' option on the server machine.  After trying to
  20985.      connect from the client machine, the information in the MySQL log
  20986.      will indicate how you really did connect.  (Then change the `'%''
  20987.      in the `user' table entry to the actual hostname that shows up in
  20988.      the log.  Otherwise, you'll have a system that is insecure because
  20989.      it allows connections from any host for the given username.)
  20990.  
  20991.      On Linux, another reason that this error might occur is that you
  20992.      are using a binary MySQL version that is compiled with a different
  20993.      version of the `glibc' library than the one you are using.  In
  20994.      this case, you should either upgrade your operating system or
  20995.      `glibc', or download a source distribution of MySQL version and
  20996.      compile it yourself.  A source RPM is normally trivial to compile
  20997.      and install, so this isn't a big problem.
  20998.  
  20999.    * If you specify a hostname when trying to connect, but get an error
  21000.      message where the hostname is not shown or is an IP number, it
  21001.      means that the MySQL server got an error when trying to resolve the
  21002.      IP number of the client host to a name:
  21003.  
  21004.           shell> mysqladmin -u root -pXXXX -h SOME-HOSTNAME ver
  21005.           Access denied for user 'root'@'' (using password: YES)
  21006.  
  21007.      This indicates a DNS problem.  To fix it, execute `mysqladmin
  21008.      flush-hosts' to reset the internal DNS hostname cache. *Note DNS::.
  21009.  
  21010.      Some permanent solutions are:
  21011.  
  21012.         - Try to find out what is wrong with your DNS server and fix it.
  21013.  
  21014.         - Specify IP numbers rather than hostnames in the MySQL grant
  21015.           tables.
  21016.  
  21017.         - Put an entry for the client machine name in `/etc/hosts'.
  21018.  
  21019.         - Start `mysqld' with the `--skip-name-resolve' option.
  21020.  
  21021.         - Start `mysqld' with the `--skip-host-cache' option.
  21022.  
  21023.         - On Unix, if you are running the server and the client on the
  21024.           same machine, connect to `localhost'. Unix connections to
  21025.           `localhost' use a Unix socket file rather than TCP/IP.
  21026.  
  21027.         - On Windows, if you are running the server and the client on
  21028.           the same machine and the server supports named pipe
  21029.           connections, connect to the hostname `.' (period).
  21030.           Connections to `.' use a named pipe rather than TCP/IP.
  21031.  
  21032.    * If `mysql -u root test' works but `mysql -h YOUR_HOSTNAME -u root
  21033.      test' results in `Access denied' (where YOUR_HOSTNAME is the
  21034.      actual hostname of the local host), you may not have the correct
  21035.      name for your host in the `user' table.  A common problem here is
  21036.      that the `Host' value in the user table entry specifies an
  21037.      unqualified hostname, but your system's name resolution routines
  21038.      return a fully qualified domain name (or vice versa).  For
  21039.      example, if you have an entry with host `'tcx'' in the `user'
  21040.      table, but your DNS tells MySQL that your hostname is
  21041.      `'tcx.subnet.se'', the entry will not work. Try adding an entry to
  21042.      the `user' table that contains the IP number of your host as the
  21043.      `Host' column value.  (Alternatively, you could add an entry to the
  21044.      `user' table with a `Host' value that contains a wildcard; for
  21045.      example, `'tcx.%''.  However, use of hostnames ending with `%' is
  21046.      _insecure_ and is _not_ recommended!)
  21047.  
  21048.    * If `mysql -u USER_NAME test' works but `mysql -u USER_NAME
  21049.      OTHER_DB_NAME' does not, you have not granted database access for
  21050.      OTHER_DB_NAME to the given user.
  21051.  
  21052.    * If `mysql -u USER_NAME' works when executed on the server host, but
  21053.      `mysql -h HOST_NAME -u USER_NAME' doesn't work when executed on a
  21054.      remote client host, you have not enabled access to the server for
  21055.      the given username from the remote host.
  21056.  
  21057.    * If you can't figure out why you get `Access denied', remove from
  21058.      the `user' table all entries that have `Host' values containing
  21059.      wildcards (entries that contain `%' or `_').  A very common error
  21060.      is to insert a new entry with `Host'=`'%'' and
  21061.      `User'=`'SOME_USER'', thinking that this will allow you to specify
  21062.      `localhost' to connect from the same machine.  The reason that this
  21063.      doesn't work is that the default privileges include an entry with
  21064.      `Host'=`'localhost'' and `User'=`'''.  Because that entry has a
  21065.      `Host' value `'localhost'' that is more specific than `'%'', it is
  21066.      used in preference to the new entry when connecting from
  21067.      `localhost'!  The correct procedure is to insert a second entry
  21068.      with `Host'=`'localhost'' and `User'=`'SOME_USER'', or to delete
  21069.      the entry with `Host'=`'localhost'' and `User'=`'''.  After
  21070.      deleting the entry, remember to issue a `FLUSH PRIVILEGES'
  21071.      statement to reload the grant tables.
  21072.  
  21073.    * If you get the following error, you may have a problem with the
  21074.      `db' or `host' table:
  21075.  
  21076.           Access to database denied
  21077.  
  21078.      If the entry selected from the `db' table has an empty value in the
  21079.      `Host' column, make sure that there are one or more corresponding
  21080.      entries in the `host' table specifying which hosts the `db' table
  21081.      entry applies to.
  21082.  
  21083.    * If you are able to connect to the MySQL server, but get an `Access
  21084.      denied' message whenever you issue a `SELECT ...  INTO OUTFILE' or
  21085.      `LOAD DATA INFILE' statement, your entry in the `user' table
  21086.      doesn't have the `FILE' privilege enabled.
  21087.  
  21088.    * If you change the grant tables directly (for example, by using
  21089.      `INSERT', `UPDATE', or `DELETE' statements) and your changes seem
  21090.      to be ignored, remember that you must execute a `FLUSH PRIVILEGES'
  21091.      statement or a `mysqladmin flush-privileges' command to cause the
  21092.      server to re-read the privilege tables. Otherwise, your changes
  21093.      have no effect until the next time the server is restarted.
  21094.      Remember that after you change the `root' password with an
  21095.      `UPDATE' command, you won't need to specify the new password until
  21096.      after you flush the privileges, because the server won't know
  21097.      you've changed the password yet!
  21098.  
  21099.    * If your privileges seem to have changed in the middle of a
  21100.      session, it may be that a MySQL administrator has changed them.
  21101.      Reloading the grant tables affects new client connections, but it
  21102.      also affects existing connections as indicated in *Note Privilege
  21103.      changes::.
  21104.  
  21105.    * If you have access problems with a Perl, PHP, Python, or ODBC
  21106.      program, try to connect to the server with `mysql -u USER_NAME
  21107.      DB_NAME' or `mysql -u USER_NAME -pYOUR_PASS DB_NAME'.  If you are
  21108.      able to connect using the `mysql' client, the problem lies with
  21109.      your program, not with the access privileges.  (There is no space
  21110.      between `-p' and the password; you can also use the
  21111.      `--password=YOUR_PASS' syntax to specify the password. If you use
  21112.      the `-p' option alone, MySQL will prompt you for the password.)
  21113.  
  21114.    * For testing, start the `mysqld' server with the
  21115.      `--skip-grant-tables' option.  Then you can change the MySQL grant
  21116.      tables and use the `mysqlaccess' script to check whether your
  21117.      modifications have the desired effect.  When you are satisfied
  21118.      with your changes, execute `mysqladmin flush-privileges' to tell
  21119.      the `mysqld' server to start using the new grant tables.
  21120.      (Reloading the grant tables overrides the `--skip-grant-tables'
  21121.      option.  This allows you to tell the server to begin using the
  21122.      grant tables again without stopping and restarting it.)
  21123.  
  21124.    * If everything else fails, start the `mysqld' server with a
  21125.      debugging option (for example, `--debug=d,general,query'). This
  21126.      will print host and user information about attempted connections,
  21127.      as well as information about each command issued. *Note Making
  21128.      trace files::.
  21129.  
  21130.    * If you have any other problems with the MySQL grant tables and
  21131.      feel you must post the problem to the mailing list, always provide
  21132.      a dump of the MySQL grant tables. You can dump the tables with the
  21133.      `mysqldump mysql' command. As always, post your problem using the
  21134.      `mysqlbug' script.  *Note Bug reports::.  In some cases, you may
  21135.      need to restart `mysqld' with `--skip-grant-tables' to run
  21136.      `mysqldump'.
  21137.  
  21138.  
  21139. Password Hashing in MySQL 4.1
  21140. -----------------------------
  21141.  
  21142. MySQL user accounts are listed in the `user' table of the `mysql'
  21143. database. Each MySQL account is assigned a password, although what is
  21144. stored in the `Password' column of the `user' table is not the
  21145. plaintext version of the password, but a hash value computed from it.
  21146. Password hash values are computed by the `PASSWORD()' function.
  21147.  
  21148. MySQL uses passwords in two phases of client/server communication:
  21149.  
  21150.    * When a client attempts to connect to the server, there is an
  21151.      initial authentication step in which the client must present a
  21152.      password that has a hash value matching the hash value stored in
  21153.      the `user' table for the account that the client wants to use.
  21154.  
  21155.    * After the client connects, it can (if it has sufficient
  21156.      privileges) set or change the password hashes for accounts listed
  21157.      in the `user' table.  The client can do this by using the
  21158.      `PASSWORD()' function to generate a password hash, or by using the
  21159.      `GRANT' or `SET PASSWORD' statements.
  21160.  
  21161.  
  21162. In other words, the server _uses_ hash values during authentication when
  21163. a client first attempts to connect. The server _generates_ hash values
  21164. if a connected client invokes the `PASSWORD()' function or uses a
  21165. `GRANT' or `SET PASSWORD' statement to set or change a password.
  21166.  
  21167. The password hashing mechanism was updated in MySQL 4.1 to provide
  21168. better security and to reduce the risk of passwords being intercepted.
  21169. However, this new mechanism is understood only by the 4.1 server and
  21170. 4.1 clients, which can result in some compatibility problems.  A 4.1
  21171. client can connect to a pre-4.1 server, because the client understands
  21172. both the old and new password hashing mechanisms. However, a pre-4.1
  21173. client that attempts to connect to a 4.1 server may run into
  21174. difficulties.  For example, a 4.0 `mysql' client that attempts to
  21175. connect to a 4.1 server may fail with the following error message:
  21176.  
  21177.      shell> mysql -h localhost -u root
  21178.      Client does not support authentication protocol requested
  21179.      by server; consider upgrading MySQL client
  21180.  
  21181. The following discussion describes the differences between the old and
  21182. new password mechanisms, and what you should do if you upgrade your
  21183. server to 4.1 but need to maintain backward compatibility with pre-4.1
  21184. clients. Additional information can be found in *Note Old client::.
  21185.  
  21186. *Note*: This discussion contrasts 4.1 behavior with pre-4.1 behavior,
  21187. but the 4.1 behavior described here actually begins with 4.1.1. MySQL
  21188. 4.1.0 is an "odd" release because it has a slightly different mechanism
  21189. than that implemented in 4.1.1 and up.  Differences between 4.1.0 and
  21190. more recent versions are described further in *Note Password hashing
  21191. 4.1.0::.
  21192.  
  21193. Prior to MySQL 4.1, password hashes computed by the `PASSWORD()'
  21194. function are 16 bytes long.  Such hashes look like this:
  21195.  
  21196.      mysql> SELECT PASSWORD('mypass');
  21197.      +--------------------+
  21198.      | PASSWORD('mypass') |
  21199.      +--------------------+
  21200.      | 6f8c114b58f2ce9e   |
  21201.      +--------------------+
  21202.  
  21203. The `Password' column of the `user' table (in which these hashes are
  21204. stored) also is 16 bytes long before MySQL 4.1.
  21205.  
  21206. As of MySQL 4.1, the `PASSWORD()' function has been modified to produce
  21207. a longer 41-byte hash value:
  21208.  
  21209.      mysql> SELECT PASSWORD('mypass');
  21210.      +-----------------------------------------------+
  21211.      | PASSWORD('mypass')                            |
  21212.      +-----------------------------------------------+
  21213.      | *43c8aa34cdc98eddd3de1fe9a9c2c2a9f92bb2098d75 |
  21214.      +-----------------------------------------------+
  21215.  
  21216. Accordingly, the `Password' column in the `user' table also must be 41
  21217. bytes long to store these values:
  21218.  
  21219.    * If you perform a new installation of MySQL 4.1, the `Password'
  21220.      column will be made 41 bytes long automatically.
  21221.  
  21222.    * If you upgrade an older installation to 4.1, you should run the
  21223.      `mysql_fix_privilege_tables' script to increase the length of the
  21224.      `Password' column from 16 to 41 bytes. (The script does not change
  21225.      existing password values, which remain 16 bytes long.)
  21226.  
  21227.  
  21228. A widened `Password' column can store password hashes in both the old
  21229. and new formats. The format of any given password hash value can be
  21230. determined two ways:
  21231.  
  21232.    * The obvious difference is the length (16 bytes versus 41 bytes).
  21233.  
  21234.    * A second difference is that password hashes in the new format
  21235.      always begin with a `*' character, whereas passwords in the old
  21236.      format never do.
  21237.  
  21238.  
  21239. The longer password hash format has better cryptographic properties, and
  21240. client authentication based on long hashes is more secure than that
  21241. based on the older short hashes.
  21242.  
  21243. The differences between short and long password hashes are relevant
  21244. both for how the server uses passwords during authentication and for
  21245. how it generates password hashes for connected clients that perform
  21246. password-changing operations.
  21247.  
  21248. The way in which the server uses password hashes during authentication
  21249. is affected by the width of the `Password' column:
  21250.  
  21251.    * If the column is short, only short-hash authentication is used.
  21252.  
  21253.    * If the column is long, it can hold either short or long hashes, and
  21254.      the server can use either format:
  21255.  
  21256.         - Pre-4.1 clients can connect, although because they know only
  21257.           about the old hashing mechanism, they can authenticate only
  21258.           for accounts that have short hashes.
  21259.  
  21260.         - 4.1 clients can authenticate for accounts that have short or
  21261.           long hashes.
  21262.  
  21263.  
  21264.  
  21265. For short-hash accounts, the authentication process is actually a bit
  21266. more secure for 4.1 clients than for older clients.  In terms of
  21267. security, the gradient from least to most secure is:
  21268.  
  21269.    * Pre-4.1 client authenticating for account with short password hash
  21270.  
  21271.    * 4.1 client authenticating for account with short password hash
  21272.  
  21273.    * 4.1 client authenticating for account with long password hash
  21274.  
  21275.  
  21276. The way in which the server generates password hashes for connected
  21277. clients is affected by the width of the `Password' column and by the
  21278. `--old-passwords' option.  A 4.1 server generates long hashes only if
  21279. certain conditions are met: The `Password' column must be wide enough
  21280. to hold long values and the `--old-passwords' option must not be given.
  21281. These conditions apply as follows:
  21282.  
  21283.    * The `Password' column must be wide enough to hold long hashes (41
  21284.      bytes).  If the column has not been updated and still has the
  21285.      pre-4.1 width of 16 bytes, the server notices that long hashes
  21286.      cannot fit into it and generates only short hashes when a client
  21287.      performs password-changing operations using `PASSWORD()', `GRANT',
  21288.      or `SET PASSWORD'.  This is the behavior that occurs if you have
  21289.      upgraded to 4.1 but have not yet run the
  21290.      `mysql_fix_privilege_tables' script to widen the `Password' column.
  21291.  
  21292.    * If the `Password' column is wide, it can store either short or long
  21293.      password hashes. In this case, `PASSWORD()', `GRANT', and `SET
  21294.      PASSWORD' generate long hashes unless the server was started with
  21295.      the `--old-passwords' option. That option forces the server to
  21296.      generate short password hashes instead.
  21297.  
  21298.  
  21299. The purpose of the `--old-passwords' option is to allow you to maintain
  21300. backward compatibility with pre-4.1 clients under circumstances where
  21301. the server would otherwise generate long password hashes. The option
  21302. doesn't affect authentication (4.1 clients can still use accounts that
  21303. have long password hashes), but it does prevent creation of a long
  21304. password hash in the `user' table as the result of a password-changing
  21305. operation. Were that to occur, the account no longer could be used by
  21306. pre-4.1 clients. Without the `--old-passwords' option, the following
  21307. undesirable scenario is possible:
  21308.  
  21309.    * An old client connects to an account that has a short password
  21310.      hash.
  21311.  
  21312.    * The client changes its own password. Without `--old-passwords',
  21313.      this results in the account having a long password hash.
  21314.  
  21315.    * The next time the old client attempts to connect to the account,
  21316.      it cannot, because the account now has a long password hash that
  21317.      requires the new hashing mechanism during authentication. (Once an
  21318.      account has a long password hash in the user table, only 4.1
  21319.      clients can authenticate for it, because pre-4.1 clients do not
  21320.      understand long hashes.)
  21321.  
  21322.  
  21323. This scenario illustrates that, if you must support older pre-4.1
  21324. clients, it is dangerous to run a 4.1 server without using the
  21325. `--old-passwords' option.  By running the server with
  21326. `--old-passwords', password-changing operations will not generate long
  21327. password hashes and thus do not cause accounts to become inaccessible
  21328. to older clients. (Those clients cannot inadvertently lock themselves
  21329. out by changing their password and ending up with a long password hash.)
  21330.  
  21331. The downside of the `--old-passwords' option is that any passwords you
  21332. create or change will use short hashes, even for 4.1 clients. Thus, you
  21333. lose the additional security provided by long password hashes. If you
  21334. want to create an account that has a long hash (for example, for use by
  21335. 4.1 clients), you must do so while running the server without
  21336. `--old-passwords'.
  21337.  
  21338. The following scenarios are possible for running a 4.1 server:
  21339.  
  21340. *Scenario 1:* Short `Password' column in user table:
  21341.  
  21342.    * Only short hashes can be stored in the `Password' column.
  21343.  
  21344.    * The server uses only short hashes during client authentication.
  21345.  
  21346.    * For connected clients, password hash-generating operations
  21347.      involving `PASSWORD()', `GRANT', or `SET PASSWORD' use short hashes
  21348.      exclusively.  Any change to an account's password results in that
  21349.      account having a short password hash.
  21350.  
  21351.    * The `--old-passwords' option can be used but is superfluous because
  21352.      with a short `Password' column, the server will generate only short
  21353.      password hashes anyway.
  21354.  
  21355.  
  21356. *Scenario 2:* Long `Password' column; server not started with
  21357. `--old-passwords' option:
  21358.  
  21359.    * Short or long hashes can be stored in the `Password' column.
  21360.  
  21361.    * 4.1 clients can authenticate for accounts that have short or long
  21362.      hashes.
  21363.  
  21364.    * Pre-4.1 clients can authenticate only for accounts that have short
  21365.      hashes.
  21366.  
  21367.    * For connected clients, password hash-generating operations
  21368.      involving `PASSWORD()', `GRANT', or `SET PASSWORD' use long hashes
  21369.      exclusively.  A change to an account's password results in that
  21370.      account having a long password hash.
  21371.  
  21372.  
  21373. As indicated earlier, a danger in this scenario is that it is possible
  21374. for accounts that have a short password hash to become inaccessible to
  21375. pre-4.1 clients. A change to such an account's password made via
  21376. `GRANT', `PASSWORD()', or `SET PASSWORD' results in the account being
  21377. given a long password hash. From that point on, no pre-4.1 client can
  21378. authenticate to that account until the client upgrades to 4.1.
  21379.  
  21380. To deal with this problem, you can change a password in a special way.
  21381. For example, normally you use `SET PASSWORD' as follows to change an
  21382. account password:
  21383.  
  21384.      mysql> SET PASSWORD FOR 'SOME_USER'@'SOME_HOST' = PASSWORD('mypass');
  21385.  
  21386. To change the password but create a short hash, use the
  21387. `OLD_PASSWORD()' function instead:
  21388.  
  21389.      mysql> SET PASSWORD FOR 'SOME_USER'@'SOME_HOST' = OLD_PASSWORD('mypass');
  21390.  
  21391. `OLD_PASSWORD()' is useful for situations in which you explicitly want
  21392. to generate a short hash.
  21393.  
  21394. *Scenario 3:* Long `Password' column; server started with
  21395. `--old-passwords' option:
  21396.  
  21397.    * Short or long hashes can be stored in the `Password' column.
  21398.  
  21399.    * 4.1 clients can authenticate for accounts that have short or long
  21400.      hashes (but note that it is possible to create long hashes only
  21401.      when the server is started without `--old-passwords').
  21402.  
  21403.    * Pre-4.1 clients can authenticate only for accounts that have short
  21404.      hashes.
  21405.  
  21406.    * For connected clients, password hash-generating operations
  21407.      involving `PASSWORD()', `GRANT', or `SET PASSWORD' use short hashes
  21408.      exclusively.  Any change to an account's password results in that
  21409.      account having a short password hash.
  21410.  
  21411.  
  21412. In this scenario, you cannot create accounts that have long password
  21413. hashes, because the `--old-passwords' option prevents generation of
  21414. long hashes.  Also, if you create an account with a long hash before
  21415. using the `--old-passwords' option, changing the account's password
  21416. while `--old-passwords' is in effect results in the account being given
  21417. a short password, causing it to lose the security benefits of a longer
  21418. hash.
  21419.  
  21420. The disadvantages for these scenarios may be summarized as follows:
  21421.  
  21422. In scenario 1, you cannot take advantage of longer hashes that provide
  21423. more secure authentication.
  21424.  
  21425. In scenario 2, accounts with short hashes become inaccessible to pre-4.1
  21426. clients if you change their passwords without explicitly using
  21427. `OLD_PASSWORD()'.
  21428.  
  21429. In scenario 3, `--old-passwords' prevents accounts with short hashes
  21430. from becoming inaccessible, but password-changing operations cause
  21431. accounts with long hashes to revert to short hashes, and you cannot
  21432. change them back to long hashes while `--old-passwords' is in effect.
  21433.  
  21434. Implications of Password Hashing Changes for Application Programs
  21435. .................................................................
  21436.  
  21437. An upgrade to MySQL 4.1 can cause a compatibility issue for
  21438. applications that use `PASSWORD()' to generate passwords for their own
  21439. purposes. Applications really should not do this, because `PASSWORD()'
  21440. should be used only to manage passwords for MySQL accounts. But some
  21441. applications use `PASSWORD()' for their own purposes anyway.
  21442.  
  21443. If you upgrade to 4.1 and run the server under conditions where it
  21444. generates long password hashes, an application that uses `PASSWORD()'
  21445. for its own passwords will break.  The recommended course of action is
  21446. to modify the application to use another function, such as `SHA1()' or
  21447. `MD5()', to produce hashed values.  If that is not possible, you can
  21448. use the `OLD_PASSWORD()' function, which is provided to generate short
  21449. hashes in the old format. But note that `OLD_PASSWORD()' may one day no
  21450. longer be supported.
  21451.  
  21452. If the server is running under circumstances where it generates short
  21453. hashes, `OLD_PASSWORD()' is available but is equivalent to `PASSWORD()'.
  21454.  
  21455. Password Hashing in MySQL 4.1.0
  21456. ...............................
  21457.  
  21458. Password hashing in MySQL 4.1.0 differs from hashing in 4.1.1 and up.
  21459. The 4.1.0 differences are:
  21460.  
  21461.    * Password hashes are 45 bytes long rather than 41 bytes.
  21462.  
  21463.    * The `PASSWORD()' function is non-repeatable.  That is, with a given
  21464.      argument X, successive calls to `PASSWORD(X)' generate different
  21465.      results.
  21466.  
  21467.  
  21468. These differences make authentication in 4.1.0 incompatible with that of
  21469. releases that follow it.  If you have upgraded to MySQL 4.1.0, it is
  21470. recommended that you upgrade to a newer version as soon as possible.
  21471. After you do, reassign any long passwords in the `user' table so that
  21472. they are compatible with the 41-byte format.
  21473.  
  21474. MySQL User Account Management
  21475. =============================
  21476.  
  21477. This section describes how to set up accounts for clients of your MySQL
  21478. server. It discusses the following topics:
  21479.  
  21480.    * The meaning of account names and passwords as used in MySQL and
  21481.      how that compares to names and passwords used by your operating
  21482.      system
  21483.  
  21484.    * How to set up new accounts and remove existing accounts
  21485.  
  21486.    * How to change passwords
  21487.  
  21488.    * Guidelines for using passwords securely
  21489.  
  21490.    * How to use secure connections with SSL
  21491.  
  21492.  
  21493. MySQL Usernames and Passwords
  21494. -----------------------------
  21495.  
  21496. A MySQL account is defined in terms of a username and the client host
  21497. or hosts from which the user can connect to the server. The account
  21498. also has a password.  There are several distinctions between the way
  21499. usernames and passwords are used by MySQL and the way they are used by
  21500. your operating system:
  21501.  
  21502.    * Usernames, as used by MySQL for authentication purposes, have
  21503.      nothing to do with usernames (login names) as used by Windows or
  21504.      Unix.  On Unix, most MySQL clients by default try to log in using
  21505.      the current Unix username as the MySQL username, but that is for
  21506.      convenience only. The default can be overridden easily, because
  21507.      client programs allow any username to be specified with a `-u' or
  21508.      `--user' option. Because this means that anyone can attempt to
  21509.      connect to the server using any username, you can't make a
  21510.      database secure in any way unless all MySQL accounts have
  21511.      passwords.  Anyone who specifies a username for an account that
  21512.      has no password will be able to connect successfully to the server.
  21513.  
  21514.    * MySQL usernames can be up to 16 characters long. Operating system
  21515.      usernames might have a different maximum length. For example, Unix
  21516.      usernames typically are limited to eight characters.
  21517.  
  21518.    * MySQL passwords have nothing to do with passwords for logging in
  21519.      to your operating system.  There is no necessary connection
  21520.      between the password you use to log in to a Windows or Unix
  21521.      machine and the password you use to access the MySQL server on
  21522.      that machine.
  21523.  
  21524.    * MySQL encrypts passwords using its own algorithm. This encryption
  21525.      is different from that used during the Unix login process.  MySQL
  21526.      password encryption is the same as that implemented by the
  21527.      `PASSWORD()' SQL function.  Unix password encryption is the same
  21528.      as that implemented by the `ENCRYPT()' SQL function.  See the
  21529.      descriptions of the `PASSWORD()' and `ENCRYPT()' functions in
  21530.      *Note Encryption functions::.  From version 4.1 on, MySQL employs
  21531.      a stronger authentication method that has better password
  21532.      protection during the connection process than in earlier versions.
  21533.      It is secure even if TCP/IP packets are sniffed or the `mysql'
  21534.      database is captured.  (In earlier versions, even though passwords
  21535.      are stored in encrypted form in the `user' table, knowledge of the
  21536.      encrypted password value could be used to connect to the MySQL
  21537.      server.)
  21538.  
  21539.  
  21540. When you install MySQL, the grant tables are populated with an initial
  21541. set of accounts. These accounts have names and access privileges that
  21542. are described in *Note Default privileges::, which also discusses how
  21543. to assign passwords to them.  Thereafter, you normally set up, modify,
  21544. and remove MySQL accounts using the `GRANT' and `REVOKE' statements.
  21545. *Note `GRANT': GRANT.
  21546.  
  21547. When you connect to a MySQL server with a command-line client, you
  21548. should specify the username and password for the account that you want
  21549. to use:
  21550.  
  21551.      shell> mysql --user=monty --password=GUESS DB_NAME
  21552.  
  21553. If you prefer short options, the command looks like this:
  21554.  
  21555.      shell> mysql -u monty -pGUESS DB_NAME
  21556.  
  21557. There must be _no space_ between the `-p' option and the following
  21558. password value.  *Note Connecting::.
  21559.  
  21560. The preceding commands include the password value on the command line,
  21561. which can be a security risk.  *Note Password security::.  To avoid
  21562. this, specify the `--password' or `-p' option without any following
  21563. password value:
  21564.  
  21565.      shell> mysql --user=monty --password DB_NAME
  21566.      shell> mysql -u monty -p DB_NAME
  21567.  
  21568. Then the client program will print a prompt and wait for you to enter
  21569. the password.  (In these examples, DB_NAME is _not_ interpreted as a
  21570. password, because it is separated from the preceding password option by
  21571. a space.)
  21572.  
  21573. On some systems, the library call that MySQL uses to prompt for a
  21574. password automatically limits the password to eight characters.  That
  21575. is a problem with the system library, not with MySQL.  Internally,
  21576. MySQL doesn't have any limit for the length of the password.  To work
  21577. around the problem, change your MySQL password to a value that is eight
  21578. or fewer characters long, or put your password in an option file.
  21579.  
  21580. Adding New User Accounts to MySQL
  21581. ---------------------------------
  21582.  
  21583. You can create MySQL accounts in two ways:
  21584.  
  21585.    * By using `GRANT' statements
  21586.  
  21587.    * By manipulating the MySQL grant tables directly
  21588.  
  21589. The preferred method is to use `GRANT' statements, because they are
  21590. more concise and less error-prone. `GRANT' is available as of MySQL
  21591. 3.22.11; its syntax is described in *Note `GRANT': GRANT.
  21592.  
  21593. Another option for creating accounts is to use one of several available
  21594. third-party programs that offer capabilities for MySQL account
  21595. administration.  `phpMyAdmin' is one such program.
  21596.  
  21597. The following examples show how to use the `mysql' client program to
  21598. set up new users.  These examples assume that privileges are set up
  21599. according to the defaults described in *Note Default privileges::.
  21600. This means that to make changes, you must connect to the MySQL server
  21601. as the MySQL `root' user, and the `root' account must have the `INSERT'
  21602. privilege for the `mysql' database and the `RELOAD' administrative
  21603. privilege.
  21604.  
  21605. First, use the `mysql' program to connect to the server as the MySQL
  21606. `root' user:
  21607.  
  21608.      shell> mysql --user=root mysql
  21609.  
  21610. If you have assigned a password to the `root' account, you'll also need
  21611. to supply a `--password' or `-p' option for this `mysql' command and
  21612. also for those later in this section.
  21613.  
  21614. After connecting to the server as `root', you can add new accounts.
  21615. The following statements use `GRANT' to set up four new accounts:
  21616.  
  21617.      mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
  21618.          ->     IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
  21619.      mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
  21620.          ->     IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
  21621.      mysql> GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost';
  21622.      mysql> GRANT USAGE ON *.* TO 'dummy'@'localhost';
  21623.  
  21624. The accounts created by these `GRANT' statements have the following
  21625. properties:
  21626.  
  21627.    * Two of the accounts have a username of `monty' and a password of
  21628.      `some_pass'. Both accounts are superuser accounts with full
  21629.      privileges to do anything. One account (`'monty'@'localhost'') can
  21630.      be used only when connecting from the local host. The other
  21631.      (`'monty'@'%'') can be used to connect from any other host.  Note
  21632.      that it is necessary to have both accounts for `monty' to be able
  21633.      to connect from anywhere as `monty'.  Without the `localhost'
  21634.      account, the anonymous-user account for `localhost' that is
  21635.      created by `mysql_install_db' would take precedence when `monty'
  21636.      connects from the local host. As a result, `monty' would be
  21637.      treated as an anonymous user.  The reason for this is that the
  21638.      anonymous-user account has a more specific `Host' column value
  21639.      than the `'monty'@'%'' account and thus comes earlier in the
  21640.      `user' table sort order.  (`user' table sorting is discussed in
  21641.      *Note Connection access::.)
  21642.  
  21643.    * One account has a username of `admin' and no password.  This
  21644.      account can be used only by connecting from the local host.  It is
  21645.      granted the `RELOAD' and `PROCESS' administrative privileges.
  21646.      These privileges allow the `admin' user to execute the `mysqladmin
  21647.      reload', `mysqladmin refresh', and `mysqladmin flush-XXX' commands,
  21648.      as well as `mysqladmin processlist' .  No privileges are granted
  21649.      for accessing any databases. You could add such privileges later
  21650.      by issuing additional `GRANT' statements.
  21651.  
  21652.    * One account has a username of `dummy' and no password.  This
  21653.      account can be used only by connecting from the local host.  No
  21654.      privileges are granted. The `USAGE' privilege in the `GRANT'
  21655.      statement allows you to create an account without giving it any
  21656.      privileges. It has the effect of setting all the global privileges
  21657.      to `'N''.  It is assumed that you will grant specific privileges
  21658.      to the account later.
  21659.  
  21660.  
  21661. As an alternative to `GRANT', you can create the same accounts directly
  21662. by issuing `INSERT' statements and then telling the server to reload
  21663. the grant tables:
  21664.  
  21665.      shell> mysql --user=root mysql
  21666.      mysql> INSERT INTO user
  21667.          ->     VALUES('localhost','monty',PASSWORD('some_pass'),
  21668.          ->     'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
  21669.      mysql> INSERT INTO user
  21670.          ->     VALUES('%','monty',PASSWORD('some_pass'),
  21671.          ->     'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
  21672.      mysql> INSERT INTO user SET Host='localhost',User='admin',
  21673.          ->     Reload_priv='Y', Process_priv='Y';
  21674.      mysql> INSERT INTO user (Host,User,Password)
  21675.          ->     VALUES('localhost','dummy','');
  21676.      mysql> FLUSH PRIVILEGES;
  21677.  
  21678. The reason for using `FLUSH PRIVILEGES' when you create accounts with
  21679. `INSERT' is to tell the server to re-read the grant tables.  Otherwise,
  21680. the changes will go unnoticed until you restart the server. With
  21681. `GRANT', `FLUSH PRIVILEGES' is unnecessary.
  21682.  
  21683. The reason for using the `PASSWORD()' function with `INSERT' is to
  21684. encrypt the password. The `GRANT' statement encrypts the password for
  21685. you, so `PASSWORD()' is unnecessary.
  21686.  
  21687. The `'Y'' values enable privileges for the accounts.  Depending on your
  21688. MySQL version, you may have to use a different number of `'Y'' values
  21689. in the first two `INSERT' statements. (Versions prior to 3.22.11 have
  21690. fewer privilege columns, and versions from 4.0.2 on have more.)  For the
  21691. `admin' account, the more readable extended `INSERT' syntax using `SET'
  21692. that is available starting with MySQL 3.22.11 is used.
  21693.  
  21694. In the `INSERT' statement for the `dummy' account, only the `Host',
  21695. `User', and `Password' columns in the `user' table record are assigned
  21696. values. None of the privilege columns are set explicitly, so MySQL
  21697. assigns them all the default value of `'N''.  This is equivalent to
  21698. what `GRANT USAGE' does.
  21699.  
  21700. Note that to set up a superuser account, it is necessary only to create
  21701. a `user' table entry with the privilege columns set to `'Y''.  `user'
  21702. table privileges are global, so no entries in any of the other grant
  21703. tables are needed.
  21704.  
  21705. The next examples create three accounts and give them access to specific
  21706. databases. Each of them has a username of `custom' and password of
  21707. `obscure'.
  21708.  
  21709. To create the accounts with `GRANT', use the following statements:
  21710.  
  21711.      shell> mysql --user=root mysql
  21712.      mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
  21713.          ->     ON bankaccount.*
  21714.          ->     TO 'custom'@'localhost'
  21715.          ->     IDENTIFIED BY 'obscure';
  21716.      mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
  21717.          ->     ON expenses.*
  21718.          ->     TO 'custom'@'whitehouse.gov'
  21719.          ->     IDENTIFIED BY 'obscure';
  21720.      mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
  21721.          ->     ON customer.*
  21722.          ->     TO 'custom'@'server.domain'
  21723.          ->     IDENTIFIED BY 'obscure';
  21724.  
  21725. The three accounts can be used as follows:
  21726.  
  21727.    * The first account can access the `bankaccount' database, but only
  21728.      from the local host.
  21729.  
  21730.    * The second account can access the `expenses' database, but only
  21731.      from the host `whitehouse.gov'.
  21732.  
  21733.    * The third account can access the `customer' database, but only
  21734.      from the host `server.domain'.
  21735.  
  21736. To set up the `custom' accounts without `GRANT', use `INSERT'
  21737. statements as follows to modify the grant tables directly:
  21738.  
  21739.      shell> mysql --user=root mysql
  21740.      mysql> INSERT INTO user (Host,User,Password)
  21741.          ->     VALUES('localhost','custom',PASSWORD('obscure'));
  21742.      mysql> INSERT INTO user (Host,User,Password)
  21743.          ->     VALUES('whitehouse.gov','custom',PASSWORD('obscure'));
  21744.      mysql> INSERT INTO user (Host,User,Password)
  21745.          ->     VALUES('server.domain','custom',PASSWORD('obscure'));
  21746.      mysql> INSERT INTO db
  21747.          ->     (Host,Db,User,Select_priv,Insert_priv,
  21748.          ->     Update_priv,Delete_priv,Create_priv,Drop_priv)
  21749.          ->     VALUES('localhost','bankaccount','custom',
  21750.          ->     'Y','Y','Y','Y','Y','Y');
  21751.      mysql> INSERT INTO db
  21752.          ->     (Host,Db,User,Select_priv,Insert_priv,
  21753.          ->     Update_priv,Delete_priv,Create_priv,Drop_priv)
  21754.          ->     VALUES('whitehouse.gov','expenses','custom',
  21755.          ->     'Y','Y','Y','Y','Y','Y');
  21756.      mysql> INSERT INTO db
  21757.          ->     (Host,Db,User,Select_priv,Insert_priv,
  21758.          ->     Update_priv,Delete_priv,Create_priv,Drop_priv)
  21759.          ->     VALUES('server.domain','customer','custom',
  21760.          ->     'Y','Y','Y','Y','Y','Y');
  21761.      mysql> FLUSH PRIVILEGES;
  21762.  
  21763. The first three `INSERT' statements add `user' table entries that allow
  21764. the user `custom' to connect from the various hosts with the given
  21765. password, but grant no global privileges (all privileges are set to the
  21766. default value of `'N'').  The next three `INSERT' statements add `db'
  21767. table entries that grant privileges to `custom' for the `bankaccount',
  21768. `expenses', and `customer' databases, but only when accessed from the
  21769. proper hosts.  As usual when you modify the grant tables directly, you
  21770. tell the server to reload them with `FLUSH PRIVILEGES' so that the
  21771. privilege changes take effect.
  21772.  
  21773. If you want to give a specific user access from all machines in a given
  21774. domain (for example, `mydomain.com'), you can issue a `GRANT' statement
  21775. that uses the `%' wildcard character in the host part of the account
  21776. name:
  21777.  
  21778.      mysql> GRANT ...
  21779.          ->     ON *.*
  21780.          ->     TO 'myname'@'%.mydomain.com'
  21781.          ->     IDENTIFIED BY 'mypass';
  21782.  
  21783. To do the same thing by modifying the grant tables directly, do this:
  21784.  
  21785.      mysql> INSERT INTO user (Host,User,Password,...)
  21786.          ->     VALUES('%.mydomain.com','myname',PASSWORD('mypass'),...);
  21787.      mysql> FLUSH PRIVILEGES;
  21788.  
  21789. Removing User Accounts from MySQL
  21790. ---------------------------------
  21791.  
  21792. To remove an account, use the `DROP USER' statement, which was added in
  21793. MySQL 4.1.1.  For older versions of MySQL, use `DELETE' instead.  The
  21794. account removal procedure is described in *Note Drop user::.
  21795.  
  21796. Limiting Account Resources
  21797. --------------------------
  21798.  
  21799. Before MySQL 4.0.2, the only available method for limiting use of MySQL
  21800. server resources is to set the `max_user_connections' system variable
  21801. to a non-zero value. But that method is strictly global.  It does not
  21802. allow for management of individual accounts. Also, it limits only the
  21803. number of simultaneous connections made using a single account, not
  21804. what a client can do once connected. Both types of control are interest
  21805. to many MySQL administrators, particularly those for Internet Service
  21806. Providers.
  21807.  
  21808. Starting from MySQL 4.0.2, you can limit the following server resources
  21809. for individual accounts:
  21810.  
  21811.    * The number of queries that an account can issue per hour
  21812.  
  21813.    * The number of updates that an account can issue per hour
  21814.  
  21815.    * The number of times an account can connect to the server per hour
  21816.  
  21817. Any statement that a client can issue counts against the query limit.
  21818. Only statements that modify databases or tables count against the update
  21819. limit.
  21820.  
  21821. An account in this context is a single record in the `user' table. Each
  21822. account is uniquely identified by its `User' and `Host' column values.
  21823.  
  21824. As a prerequisite for using this feature, the `user' table in the
  21825. `mysql' database must contain the resource-related columns.  Resource
  21826. limits are stored in the `max_questions', `max_updates', and
  21827. `max_connections' columns.  If your `user' table doesn't have these
  21828. columns, it must be upgraded; see *Note Upgrading-grant-tables::.
  21829.  
  21830. To set resource limits with a `GRANT' statement, use a `WITH' clause
  21831. that names each resource to be limited and a per-hour count indicating
  21832. the limit value.  For example, to create a new account that can access
  21833. the `customer' database, but only in a limited fashion, issue this
  21834. statement:
  21835.  
  21836.      mysql> GRANT ALL ON customer.* TO 'francis'@'localhost'
  21837.          ->     IDENTIFIED BY 'frank'
  21838.          ->     WITH MAX_QUERIES_PER_HOUR 20
  21839.          ->          MAX_UPDATES_PER_HOUR 10
  21840.          ->          MAX_CONNECTIONS_PER_HOUR 5;
  21841.  
  21842. The limit types need not all be named in the `WITH' clause, but those
  21843. named can be present in any order. The value for each limit should be an
  21844. integer representing a count per hour. If the `GRANT' statement has no
  21845. `WITH' clause, the limits are each set to the default value of zero
  21846. (that is, no limit).
  21847.  
  21848. To set or change limits for an existing account, use a `GRANT USAGE'
  21849. statement at the global level (`ON *.*'). The following statement
  21850. changes the query limit for `francis' to 100:
  21851.  
  21852.      mysql> GRANT USAGE ON *.* TO 'francis'@'localhost'
  21853.          ->     WITH MAX_QUERIES_PER_HOUR 100;
  21854.  
  21855. This statement leaves the account's existing privileges unchanged and
  21856. modifies only the limit values specified.
  21857.  
  21858. To remove an existing limit, set its value to zero. For example, to
  21859. remove the limit on how many times per hour `francis' can connect, use
  21860. this statement:
  21861.  
  21862.      mysql> GRANT USAGE ON *.* TO 'francis'@'localhost'
  21863.          ->     WITH MAX_CONNECTIONS_PER_HOUR 0;
  21864.  
  21865. Resource-use counting takes place when any account has a non-zero limit
  21866. placed on its use of any of the resources.
  21867.  
  21868. As the server runs, it counts the number of times each account uses
  21869. resources.  If an account reaches its limit on number of connections
  21870. within the last hour, further connections for the account are rejected
  21871. until that hour is up. Similarly, if the account reaches its limit on
  21872. the number of queries or updates, further queries or updates are
  21873. rejected until the hour is up. In all such cases, an appropriate error
  21874. message is issued.
  21875.  
  21876. Resource counting is done per account, not per client. For example, if
  21877. your account has a query limit of 50, you cannot increase your limit to
  21878. 100 by making two simultaneous client connections to the server.
  21879. Queries issued on both connections are counted together.
  21880.  
  21881. The current resource-use counts can be reset globally for all accounts,
  21882. or individually for a given count:
  21883.  
  21884.    * To reset the current counts to zero for all accounts, issue a
  21885.      `FLUSH USER_RESOURCES' statement. The counts also can be reset by
  21886.      reloading the grant tables (for example, with a `FLUSH PRIVILEGES'
  21887.      statement or a `mysqladmin reload' command).
  21888.  
  21889.    * The counts for an individual account can be set to zero by
  21890.      re-granting it any of its limits. To do this, use `GRANT USAGE' as
  21891.      described earlier and specify a limit value equal to the value
  21892.      that the account already has.
  21893.  
  21894.  
  21895. Assigning Account Passwords
  21896. ---------------------------
  21897.  
  21898. Passwords may be assigned from the command line by using the
  21899. `mysqladmin' command:
  21900.  
  21901.      shell> mysqladmin -u USER_NAME -h HOST_NAME password "NEWPWD"
  21902.  
  21903. The account for which this command resets the password is the one with a
  21904. `user' table record that matches USER_NAME in the `User' column and the
  21905. client host _from which you connect_ in the `Host' column.
  21906.  
  21907. Another way to assign a password to an account is to issue a `SET
  21908. PASSWORD' statement:
  21909.  
  21910.      mysql> SET PASSWORD FOR 'jeffrey'@'%' = PASSWORD('biscuit');
  21911.  
  21912. Only users such as `root' with update access to the `mysql' database
  21913. can change the password for other users.  If you are not connected as
  21914. an anonymous user, you can change your own password by omitting the
  21915. `FOR' clause:
  21916.  
  21917.      mysql> SET PASSWORD = PASSWORD('biscuit');
  21918.  
  21919. You can also use a `GRANT USAGE' statement at the global level (`ON
  21920. *.*') to assign a password to an account without affecting the
  21921. account's current privileges:
  21922.  
  21923.      mysql> GRANT USAGE ON *.* TO 'jeffrey'@'%' IDENTIFIED BY 'biscuit';
  21924.  
  21925. Although it is generally preferable to assign passwords using one of the
  21926. preceding methods, you can also do so by modifying the `user' table
  21927. directly:
  21928.  
  21929.    * To establish a password when creating a new account, provide a
  21930.      value for the `Password' column:
  21931.  
  21932.           shell> mysql -u root mysql
  21933.           mysql> INSERT INTO user (Host,User,Password)
  21934.               -> VALUES('%','jeffrey',PASSWORD('biscuit'));
  21935.           mysql> FLUSH PRIVILEGES;
  21936.  
  21937.    * To change the password for an existing account, use `UPDATE' to
  21938.      set the `Password' column value:
  21939.  
  21940.           shell> mysql -u root mysql
  21941.           mysql> UPDATE user SET Password = PASSWORD('bagel')
  21942.               -> WHERE Host = '%' AND User = 'francis';
  21943.           mysql> FLUSH PRIVILEGES;
  21944.  
  21945.  
  21946. When you assign an account a password using `SET PASSWORD', `INSERT',
  21947. or `UPDATE', you must use the `PASSWORD()' function to encrypt it.
  21948. (The only exception is that you need not use `PASSWORD()' if the
  21949. password is empty.) `PASSWORD()' is necessary because the `user' table
  21950. stores passwords in encrypted form, not as plaintext.  If you forget
  21951. that fact, you are likely to set passwords like this:
  21952.  
  21953.      shell> mysql -u root mysql
  21954.      mysql> INSERT INTO user (Host,User,Password)
  21955.          -> VALUES('%','jeffrey','biscuit');
  21956.      mysql> FLUSH PRIVILEGES;
  21957.  
  21958. The result is that the literal value `'biscuit'' is stored as the
  21959. password in the `user' table, not the encrypted value.  When `jeffrey'
  21960. attempts to connect to the server using this password, the value is
  21961. encrypted and compared to the value stored in the `user' table.
  21962. However, the stored value is the literal string `'biscuit'', so the
  21963. comparison fails and the server rejects the connection:
  21964.  
  21965.      shell> mysql -u jeffrey -pbiscuit test
  21966.      Access denied
  21967.  
  21968. If you set passwords using the `GRANT ... IDENTIFIED BY' statement or
  21969. the `mysqladmin password' command, they both take care of encrypting
  21970. the password for you.  The `PASSWORD()' function is unnecessary.
  21971.  
  21972. *Note*: `PASSWORD()' encryption is different from Unix password
  21973. encryption.  *Note User names::.
  21974.  
  21975. Keeping Your Password Secure
  21976. ----------------------------
  21977.  
  21978. On an administrative level, you should never grant access to the
  21979. `mysql.user' table to any non-administrative accounts. Passwords in the
  21980. `user' table are stored in encrypted form, but in versions of MySQL
  21981. earlier than 4.1, knowing the encrypted password for an account makes it
  21982. possible to connect to the server using that account.
  21983.  
  21984. When you run a client program to connect to the MySQL server, it is
  21985. inadvisable to specify your password in a way that exposes it to
  21986. discovery by other users.  The methods you can use to specify your
  21987. password when you run client programs are listed here, along with an
  21988. assessment of the risks of each method:
  21989.  
  21990.    * Use a `-pYOUR_PASS' or `--password=YOUR_PASS' option on the command
  21991.      line.  For example:
  21992.  
  21993.           shell> mysql -u francis -pfrank DB_NAME
  21994.  
  21995.      This is convenient but insecure, because your password becomes
  21996.      visible to system status programs such as `ps' that may be invoked
  21997.      by other users to display command lines.  MySQL clients typically
  21998.      overwrite the command-line password argument with zeros during
  21999.      their initialization sequence, but there is still a brief interval
  22000.      during which the value is visible.
  22001.  
  22002.    * Use a `-p' or `--password' option with no password value
  22003.      specified.  In this case, the client program solicits the password
  22004.      from the terminal:
  22005.  
  22006.           shell> mysql -u francis -p DB_NAME
  22007.           Enter password: ********
  22008.  
  22009.      The `*' characters indicate where you enter your password. The
  22010.      password is not displayed as you enter it.
  22011.  
  22012.      It is more secure to enter your password this way than to specify
  22013.      it on the command line because it is not visible to other users.
  22014.      However, this method of entering a password is suitable only for
  22015.      programs that you run interactively.  If you want to invoke a
  22016.      client from a script that runs non-interactively, there is no
  22017.      opportunity to enter the password from the terminal. On some
  22018.      systems, you may even find that the first line of your script is
  22019.      read and interpreted (incorrectly) as your password!
  22020.  
  22021.    * Store your password in an option file.  For example, on Unix you
  22022.      can list your password in the `[client]' section of the `.my.cnf'
  22023.      file in your home directory:
  22024.  
  22025.           [client]
  22026.           password=your_pass
  22027.  
  22028.      If you store your password in `.my.cnf', the file should not be
  22029.      accessible to anyone but yourself. To ensure this, set the file
  22030.      access mode to `400' or `600'. For example:
  22031.  
  22032.           shell> chmod 600 .my.cnf
  22033.  
  22034.      *Note Option files:: discusses option files in more detail.
  22035.  
  22036.    * Store your password in the `MYSQL_PWD' environment variable.  This
  22037.      method of specifying your MySQL password must be considered
  22038.      extremely insecure and should not be used.  Some versions of `ps'
  22039.      include an option to display the environment of running processes.
  22040.      If you set `MYSQL_PWD', your password will be exposed to any other
  22041.      user who runs `ps'.  Even on systems without such a version of
  22042.      `ps', it is unwise to assume that there are no other methods by
  22043.      which users can examine process environments.  *Note Environment
  22044.      variables::.
  22045.  
  22046.  
  22047. All in all, the safest methods are to have the client program prompt
  22048. for the password or to specify the password in a properly protected
  22049. option file.
  22050.  
  22051. Using Secure Connections
  22052. ------------------------
  22053.  
  22054. Beginning with version 4.0.0, MySQL has support for secure (encrypted)
  22055. connections between MySQL clients and the server using the Secure
  22056. Sockets Layer (SSL) protocol.  This section discusses how to use SSL
  22057. connections.  It also describes a way to set up SSH on Windows.
  22058.  
  22059. The standard configuration of MySQL is intended to be as fast as
  22060. possible, so encrypted connections are not used by default.  Doing so
  22061. would make the client/server protocol much slower.  Encrypting data is
  22062. a CPU-intensive operation that requires the computer to do additional
  22063. work and can delay other MySQL tasks.  For applications that require
  22064. the security provided by encrypted connections, the extra computation
  22065. is warranted.
  22066.  
  22067. MySQL allows encryption to be enabled on a per-connection basis. You can
  22068. choose a normal unencrypted connection or a secure encrypted SSL
  22069. connection according the requirements of individual applications.
  22070.  
  22071. Basic SSL Concepts
  22072. ..................
  22073.  
  22074. To understand how MySQL uses SSL, it's necessary to explain some basic
  22075. SSL and X509 concepts. People who are already familiar with them can
  22076. skip this part.
  22077.  
  22078. By default, MySQL uses unencrypted connections between the client and
  22079. the server. This means that someone with access to the network could
  22080. watch all your traffic and look at the data being sent or received.
  22081. They could even change the data while it is in transit between client
  22082. and server. To improve security a little, you can compress
  22083. client/server traffic by using the `--compress' option when invoking
  22084. client programs.  However, this will not foil a determined attacker.
  22085.  
  22086. When you need to move information over a network in a secure fashion,
  22087. an unencrypted connection is unacceptable.  Encryption is the way to
  22088. make any kind of data unreadable. In fact, today's practice requires
  22089. many additional security elements from encryption algorithms.  They
  22090. should resist many kind of known attacks such as changing the order of
  22091. encrypted messages or replaying data twice.
  22092.  
  22093. SSL is a protocol that uses different encryption algorithms to ensure
  22094. that data received over a public network can be trusted. It has
  22095. mechanisms to detect any data change, loss, or replay. SSL also
  22096. incorporates algorithms that provide identity verification using the
  22097. X509 standard.
  22098.  
  22099. X509 makes it possible to identify someone on the Internet.  It is most
  22100. commonly used in e-commerce applications. In basic terms, there should
  22101. be some company called a "Certificate Authority" (or CA) that assigns
  22102. electronic certificates to anyone who needs them. Certificates rely on
  22103. asymmetric encryption algorithms that have two encryption keys (a
  22104. public key and a secret key). A certificate owner can show the
  22105. certificate to another party as proof of identity. A certificate
  22106. consists of its owner's public key. Any data encrypted with this public
  22107. key can be decrypted only using the corresponding secret key, which is
  22108. held by the owner of the certificate.
  22109.  
  22110. If you need more information about SSL, X509, or encryption, use your
  22111. favorite Internet search engine to search for keywords in which you are
  22112. interested.
  22113.  
  22114. Requirements
  22115. ............
  22116.  
  22117. To use SSL connections between the MySQL server and client programs,
  22118. your system must be able to support OpenSSL and your version of MySQL
  22119. must be 4.0.0 or newer.
  22120.  
  22121. To get secure connections to work with MySQL, you must do the following:
  22122.  
  22123.   1. Install the OpenSSL library. We have tested MySQL with OpenSSL
  22124.      0.9.6.  If you need OpenSSL, visit `http://www.openssl.org'.
  22125.  
  22126.   2. When you configure MySQL, run the `configure' script with the
  22127.      `--with-vio' and `--with-openssl' options.
  22128.  
  22129.   3. Make sure that you have upgraded your grant tables to include the
  22130.      SSL-related columns in the `mysql.user' table.  This is necessary
  22131.      if your grant tables date from a version prior to MySQL 4.0.0.
  22132.      The upgrade procedure is described in *Note
  22133.      Upgrading-grant-tables::.
  22134.  
  22135.   4. To check whether a running `mysqld' server supports OpenSSL,
  22136.      examine the value of the `have_openssl' system variable:
  22137.  
  22138.           mysql> SHOW VARIABLES LIKE 'have_openssl';
  22139.           +---------------+-------+
  22140.           | Variable_name | Value |
  22141.           +---------------+-------+
  22142.           | have_openssl  | YES   |
  22143.           +---------------+-------+
  22144.  
  22145.      If the value is `YES', the server supports OpenSSL connections.
  22146.  
  22147. Setting Up SSL Certificates for MySQL
  22148. .....................................
  22149.  
  22150. Here is an example for setting up SSL certificates for MySQL:
  22151.  
  22152.      DIR=`pwd`/openssl
  22153.      PRIV=$DIR/private
  22154.      
  22155.      mkdir $DIR $PRIV $DIR/newcerts
  22156.      cp /usr/share/ssl/openssl.cnf $DIR
  22157.      replace ./demoCA $DIR -- $DIR/openssl.cnf
  22158.      
  22159.      # Create necessary files: $database, $serial and $new_certs_dir
  22160.      # directory (optional)
  22161.      
  22162.      touch $DIR/index.txt
  22163.      echo "01" > $DIR/serial
  22164.      
  22165.      #
  22166.      # Generation of Certificate Authority(CA)
  22167.      #
  22168.      
  22169.      openssl req -new -x509 -keyout $PRIV/cakey.pem -out $DIR/cacert.pem \
  22170.          -config $DIR/openssl.cnf
  22171.      
  22172.      # Sample output:
  22173.      # Using configuration from /home/monty/openssl/openssl.cnf
  22174.      # Generating a 1024 bit RSA private key
  22175.      # ................++++++
  22176.      # .........++++++
  22177.      # writing new private key to '/home/monty/openssl/private/cakey.pem'
  22178.      # Enter PEM pass phrase:
  22179.      # Verifying password - Enter PEM pass phrase:
  22180.      # -----
  22181.      # You are about to be asked to enter information that will be
  22182.      # incorporated into your certificate request.
  22183.      # What you are about to enter is what is called a Distinguished Name
  22184.      # or a DN.
  22185.      # There are quite a few fields but you can leave some blank
  22186.      # For some fields there will be a default value,
  22187.      # If you enter '.', the field will be left blank.
  22188.      # -----
  22189.      # Country Name (2 letter code) [AU]:FI
  22190.      # State or Province Name (full name) [Some-State]:.
  22191.      # Locality Name (eg, city) []:
  22192.      # Organization Name (eg, company) [Internet Widgits Pty Ltd]:MySQL AB
  22193.      # Organizational Unit Name (eg, section) []:
  22194.      # Common Name (eg, YOUR name) []:MySQL admin
  22195.      # Email Address []:
  22196.      
  22197.      #
  22198.      # Create server request and key
  22199.      #
  22200.      openssl req -new -keyout $DIR/server-key.pem -out \
  22201.          $DIR/server-req.pem -days 3600 -config $DIR/openssl.cnf
  22202.      
  22203.      # Sample output:
  22204.      # Using configuration from /home/monty/openssl/openssl.cnf
  22205.      # Generating a 1024 bit RSA private key
  22206.      # ..++++++
  22207.      # ..........++++++
  22208.      # writing new private key to '/home/monty/openssl/server-key.pem'
  22209.      # Enter PEM pass phrase:
  22210.      # Verifying password - Enter PEM pass phrase:
  22211.      # -----
  22212.      # You are about to be asked to enter information that will be
  22213.      # incorporated into your certificate request.
  22214.      # What you are about to enter is what is called a Distinguished Name
  22215.      # or a DN.
  22216.      # There are quite a few fields but you can leave some blank
  22217.      # For some fields there will be a default value,
  22218.      # If you enter '.', the field will be left blank.
  22219.      # -----
  22220.      # Country Name (2 letter code) [AU]:FI
  22221.      # State or Province Name (full name) [Some-State]:.
  22222.      # Locality Name (eg, city) []:
  22223.      # Organization Name (eg, company) [Internet Widgits Pty Ltd]:MySQL AB
  22224.      # Organizational Unit Name (eg, section) []:
  22225.      # Common Name (eg, YOUR name) []:MySQL server
  22226.      # Email Address []:
  22227.      #
  22228.      # Please enter the following 'extra' attributes
  22229.      # to be sent with your certificate request
  22230.      # A challenge password []:
  22231.      # An optional company name []:
  22232.      
  22233.      #
  22234.      # Remove the passphrase from the key (optional)
  22235.      #
  22236.      
  22237.      openssl rsa -in $DIR/server-key.pem -out $DIR/server-key.pem
  22238.      
  22239.      #
  22240.      # Sign server cert
  22241.      #
  22242.      openssl ca  -policy policy_anything -out $DIR/server-cert.pem \
  22243.          -config $DIR/openssl.cnf -infiles $DIR/server-req.pem
  22244.      
  22245.      # Sample output:
  22246.      # Using configuration from /home/monty/openssl/openssl.cnf
  22247.      # Enter PEM pass phrase:
  22248.      # Check that the request matches the signature
  22249.      # Signature ok
  22250.      # The Subjects Distinguished Name is as follows
  22251.      # countryName           :PRINTABLE:'FI'
  22252.      # organizationName      :PRINTABLE:'MySQL AB'
  22253.      # commonName            :PRINTABLE:'MySQL admin'
  22254.      # Certificate is to be certified until Sep 13 14:22:46 2003 GMT
  22255.      # (365 days)
  22256.      # Sign the certificate? [y/n]:y
  22257.      #
  22258.      #
  22259.      # 1 out of 1 certificate requests certified, commit? [y/n]y
  22260.      # Write out database with 1 new entries
  22261.      # Data Base Updated
  22262.      
  22263.      #
  22264.      # Create client request and key
  22265.      #
  22266.      openssl req -new -keyout $DIR/client-key.pem -out \
  22267.          $DIR/client-req.pem -days 3600 -config $DIR/openssl.cnf
  22268.      
  22269.      # Sample output:
  22270.      # Using configuration from /home/monty/openssl/openssl.cnf
  22271.      # Generating a 1024 bit RSA private key
  22272.      # .....................................++++++
  22273.      # .............................................++++++
  22274.      # writing new private key to '/home/monty/openssl/client-key.pem'
  22275.      # Enter PEM pass phrase:
  22276.      # Verifying password - Enter PEM pass phrase:
  22277.      # -----
  22278.      # You are about to be asked to enter information that will be
  22279.      # incorporated into your certificate request.
  22280.      # What you are about to enter is what is called a Distinguished Name
  22281.      # or a DN.
  22282.      # There are quite a few fields but you can leave some blank
  22283.      # For some fields there will be a default value,
  22284.      # If you enter '.', the field will be left blank.
  22285.      # -----
  22286.      # Country Name (2 letter code) [AU]:FI
  22287.      # State or Province Name (full name) [Some-State]:.
  22288.      # Locality Name (eg, city) []:
  22289.      # Organization Name (eg, company) [Internet Widgits Pty Ltd]:MySQL AB
  22290.      # Organizational Unit Name (eg, section) []:
  22291.      # Common Name (eg, YOUR name) []:MySQL user
  22292.      # Email Address []:
  22293.      #
  22294.      # Please enter the following 'extra' attributes
  22295.      # to be sent with your certificate request
  22296.      # A challenge password []:
  22297.      # An optional company name []:
  22298.      
  22299.      #
  22300.      # Remove a passphrase from the key (optional)
  22301.      #
  22302.      openssl rsa -in $DIR/client-key.pem -out $DIR/client-key.pem
  22303.      
  22304.      #
  22305.      # Sign client cert
  22306.      #
  22307.      
  22308.      openssl ca  -policy policy_anything -out $DIR/client-cert.pem \
  22309.          -config $DIR/openssl.cnf -infiles $DIR/client-req.pem
  22310.      
  22311.      # Sample output:
  22312.      # Using configuration from /home/monty/openssl/openssl.cnf
  22313.      # Enter PEM pass phrase:
  22314.      # Check that the request matches the signature
  22315.      # Signature ok
  22316.      # The Subjects Distinguished Name is as follows
  22317.      # countryName           :PRINTABLE:'FI'
  22318.      # organizationName      :PRINTABLE:'MySQL AB'
  22319.      # commonName            :PRINTABLE:'MySQL user'
  22320.      # Certificate is to be certified until Sep 13 16:45:17 2003 GMT
  22321.      # (365 days)
  22322.      # Sign the certificate? [y/n]:y
  22323.      #
  22324.      #
  22325.      # 1 out of 1 certificate requests certified, commit? [y/n]y
  22326.      # Write out database with 1 new entries
  22327.      # Data Base Updated
  22328.      
  22329.      #
  22330.      # Create a my.cnf file that you can use to test the certificates
  22331.      #
  22332.      
  22333.      cnf=""
  22334.      cnf="$cnf [client]"
  22335.      cnf="$cnf ssl-ca=$DIR/cacert.pem"
  22336.      cnf="$cnf ssl-cert=$DIR/client-cert.pem"
  22337.      cnf="$cnf ssl-key=$DIR/client-key.pem"
  22338.      cnf="$cnf [mysqld]"
  22339.      cnf="$cnf ssl-ca=$DIR/cacert.pem"
  22340.      cnf="$cnf ssl-cert=$DIR/server-cert.pem"
  22341.      cnf="$cnf ssl-key=$DIR/server-key.pem"
  22342.      echo $cnf | replace " " '
  22343.      ' > $DIR/my.cnf
  22344.  
  22345. To test SSL connections, start the server as follows, where `$DIR' is
  22346. the pathname to the directory where the sample `my.cnf' option file is
  22347. located:
  22348.  
  22349.      shell> mysqld --defaults-file=$DIR/my.cnf &
  22350.  
  22351. Then invoke a client program using the same option file:
  22352.  
  22353.      shell> mysql --defaults-file=$DIR/my.cnf
  22354.  
  22355. If you have a MySQL source distribution, you can also test your setup by
  22356. modifying the preceding `my.cnf' file to refer to the demonstration
  22357. certificate and key files in the `SSL' directory of the distribution.
  22358.  
  22359. SSL `GRANT' Options
  22360. ...................
  22361.  
  22362. MySQL can check X509 certificate attributes in addition to the usual
  22363. authentication that is based on the username and password.  To specify
  22364. SSL-related options for a MySQL account, use the `REQUIRE' clause of
  22365. the `GRANT' statement.  *Note `GRANT': GRANT.
  22366.  
  22367. There are different possibilities for limiting connection types for an
  22368. account:
  22369.  
  22370.    * If an account has no SSL or X509 requirements, unencrypted
  22371.      connections are allowed if the username and password are valid.
  22372.      However, encrypted connections also can be used at the client's
  22373.      option, if the client has the proper certificate and key files.
  22374.  
  22375.    * `REQUIRE SSL' option limits the server to allow only SSL encrypted
  22376.      connections for the account. Note that this option can be omitted
  22377.      if there are any ACL records that allow non-SSL connections.
  22378.  
  22379.           mysql> GRANT ALL PRIVILEGES ON test.* TO 'root'@'localhost'
  22380.               -> IDENTIFIED BY 'goodsecret' REQUIRE SSL;
  22381.  
  22382.    * `REQUIRE X509' means that the client must have a valid certificate
  22383.      but that the exact certificate, issuer, and subject do not matter.
  22384.      The only requirement is that it should be possible to verify its
  22385.      signature with one of the CA certificates.
  22386.  
  22387.           mysql> GRANT ALL PRIVILEGES ON test.* TO 'root'@'localhost'
  22388.               -> IDENTIFIED BY 'goodsecret' REQUIRE X509;
  22389.  
  22390.    * `REQUIRE ISSUER 'issuer'' places the restriction on connection
  22391.      attempts that the client must present a valid X509 certificate
  22392.      issued by CA `'issuer''.  If the client presents a certificate
  22393.      that is valid but has a different issuer, the server rejects the
  22394.      connection.  Use of X509 certificates always implies encryption,
  22395.      so the `SSL' option is unneccessary.
  22396.  
  22397.           mysql> GRANT ALL PRIVILEGES ON test.* TO 'root'@'localhost'
  22398.               -> IDENTIFIED BY 'goodsecret'
  22399.               -> REQUIRE ISSUER '/C=FI/ST=Some-State/L=Helsinki/
  22400.                  O=MySQL Finland AB/CN=Tonu Samuel/Email=tonu@example.com';
  22401.  
  22402.      Note that the `ISSUER' value should be entered as a single string.
  22403.  
  22404.    * `REQUIRE SUBJECT 'subject'' places the restriction on connection
  22405.      attempts that the client must present a valid X509 certificate
  22406.      with subject `'subject'' on it.  If the client presents a
  22407.      certificate that is valid but has a different subject, the server
  22408.      rejects the connection.
  22409.  
  22410.           mysql> GRANT ALL PRIVILEGES ON test.* TO 'root'@'localhost'
  22411.               -> IDENTIFIED BY 'goodsecret'
  22412.               -> REQUIRE SUBJECT '/C=EE/ST=Some-State/L=Tallinn/
  22413.                  O=MySQL demo client certificate/
  22414.                  CN=Tonu Samuel/Email=tonu@example.com';
  22415.  
  22416.      Note that the `SUBJECT' value should be entered as a single string.
  22417.  
  22418.    * `REQUIRE CIPHER 'cipher'' is needed to ensure that strong enough
  22419.      ciphers and key lengths will be used. SSL itself can be weak if
  22420.      old algorithms with short encryption keys are used. Using this
  22421.      option, we can ask for some exact cipher method to allow a
  22422.      connection.
  22423.  
  22424.           mysql> GRANT ALL PRIVILEGES ON test.* TO 'root'@'localhost'
  22425.               -> IDENTIFIED BY 'goodsecret'
  22426.               -> REQUIRE CIPHER 'EDH-RSA-DES-CBC3-SHA';
  22427.  
  22428.  
  22429. The `SUBJECT', `ISSUER', and `CIPHER' options can be combined in the
  22430. `REQUIRE' clause like this:
  22431.  
  22432.      mysql> GRANT ALL PRIVILEGES ON test.* TO 'root'@'localhost'
  22433.          -> IDENTIFIED BY 'goodsecret'
  22434.          -> REQUIRE SUBJECT '/C=EE/ST=Some-State/L=Tallinn/
  22435.             O=MySQL demo client certificate/
  22436.             CN=Tonu Samuel/Email=tonu@example.com'
  22437.          -> AND ISSUER '/C=FI/ST=Some-State/L=Helsinki/
  22438.             O=MySQL Finland AB/CN=Tonu Samuel/Email=tonu@example.com'
  22439.          -> AND CIPHER 'EDH-RSA-DES-CBC3-SHA';
  22440.  
  22441. Note that the `SUBJECT' and `ISSUER' values each should be entered as a
  22442. single string.
  22443.  
  22444. Starting from MySQL 4.0.4, the `AND' keyword is optional between
  22445. `REQUIRE' options.
  22446.  
  22447. The order of the options does not matter, but no option can be specified
  22448. twice.
  22449.  
  22450. SSL Command-Line Options
  22451. ........................
  22452.  
  22453. The following list describes options that are used for specifying the
  22454. use of SSL, certificate files, and key files.  These options are
  22455. available beginning with MySQL 4.0. They may be given on the command
  22456. line or in an option file.
  22457.  
  22458. `--ssl'
  22459.      For the server, this option specifies that the server allows SSL
  22460.      connections.  For a client program, it allows the client to
  22461.      connect to the server using SSL.  This option is not sufficient in
  22462.      itself to cause an SSL connection to be used.  You must also
  22463.      specify the `--ssl-ca', `--ssl-cert', and `--ssl-key' options.
  22464.  
  22465.      This option is more often used in its opposite form to indicate
  22466.      that SSL should _not_ be used. To do this, specify the option as
  22467.      `--skip-ssl' or `--ssl=0'.
  22468.  
  22469.      Note that use of `--ssl' doesn't _require_ an SSL connection.  For
  22470.      example, if the server or client is compiled without SSL support,
  22471.      a normal unencrypted connection will be used.
  22472.  
  22473.      The secure way to ensure that an SSL connection will be used is to
  22474.      create an account on the server that includes a `REQUIRE SSL'
  22475.      clause in the `GRANT' statement.  Then use this account to connect
  22476.      to the server, with both a server and client that have SSL support
  22477.      enabled.
  22478.  
  22479. `--ssl-ca=FILE_NAME'
  22480.      The path to a file with a list of trusted SSL CAs.
  22481.  
  22482. `--ssl-capath=DIRECTORY_NAME'
  22483.      The path to a directory that contains trusted SSL CA certificates
  22484.      in pem format.
  22485.  
  22486. `--ssl-cert=FILE_NAME'
  22487.      The name of the SSL certificate file to use for establishing a
  22488.      secure connection.
  22489.  
  22490. `--ssl-cipher=CIPHER_LIST'
  22491.      A list of allowable ciphers to use for SSL encryption.
  22492.      CIPHER_LIST has the same format as the `openssl ciphers' command.
  22493.  
  22494.      Example: `--ssl-cipher=ALL:-AES:-EXP'
  22495.  
  22496. `--ssl-key=FILE_NAME'
  22497.      The name of the SSL key file to use for establishing a secure
  22498.      connection.
  22499.  
  22500. Connecting to MySQL Remotely from Windows with SSH
  22501. ..................................................
  22502.  
  22503. Here is a note about how to connect to get a secure connection to remote
  22504. MySQL server with SSH (by David Carlson <dcarlson@mplcomm.com>):
  22505.  
  22506.   1. Install an SSH client on your Windows machine.  As a user, the
  22507.      best non-free one I've found is from `SecureCRT' from
  22508.      `http://www.vandyke.com/'.  Another option is `f-secure' from
  22509.      `http://www.f-secure.com/'. You can also find some free ones on
  22510.      `Google' at
  22511.      `http://directory.google.com/Top/Computers/Security/Products_and_Tools/Cryptography/SSH/Clients/Windows/'.
  22512.  
  22513.   2. Start your Windows SSH client.  Set `Host_Name =
  22514.      yourmysqlserver_URL_or_IP'.  Set `userid=your_userid' to log in to
  22515.      your server. This `userid' value may not be the same as the
  22516.      username of your MySQL account.
  22517.  
  22518.   3. Set up port forwarding. Either do a remote forward (Set
  22519.      `local_port: 3306', `remote_host: yourmysqlservername_or_ip',
  22520.      `remote_port: 3306' ) or a local forward (Set `port: 3306',
  22521.      `host: localhost', `remote port: 3306').
  22522.  
  22523.   4. Save everything, otherwise you'll have to redo it the next time.
  22524.  
  22525.   5. Log in to your server with the SSH session you just created.
  22526.  
  22527.   6. On your Windows machine, start some ODBC application (such as
  22528.      Access).
  22529.  
  22530.   7. Create a new file in Windows and link to MySQL using the ODBC
  22531.      driver the same way you normally do, except type in `localhost'
  22532.      for the MySQL host server, not `yourmysqlservername'.
  22533.  
  22534. You should now have an ODBC connection to MySQL, encrypted using SSH.
  22535.  
  22536. Disaster Prevention and Recovery
  22537. ================================
  22538.  
  22539. This section discusses how to make database backups and how to perform
  22540. table maintenance.  The syntax of the SQL statements described here is
  22541. given in *Note Database Administration::.  Much of the information here
  22542. pertains primarily to `MyISAM' tables.  `InnoDB' backup procedures are
  22543. given in *Note Backing up::.
  22544.  
  22545. Database Backups
  22546. ----------------
  22547.  
  22548. Because MySQL tables are stored as files, it is easy to do a backup. To
  22549. get a consistent backup, do a `LOCK TABLES' on the relevant tables,
  22550. followed by `FLUSH TABLES' for the tables.  See *Note `LOCK TABLES':
  22551. LOCK TABLES and *Note `FLUSH': FLUSH.  You need only a read lock; this
  22552. allows other clients to continue to query the tables while you are
  22553. making a copy of the files in the database directory.  The `FLUSH
  22554. TABLES' statement is needed to ensure that the all active index pages
  22555. are written to disk before you start the backup.
  22556.  
  22557. If you want to make an SQL-level backup of a table, you can use `SELECT
  22558. INTO ... OUTFILE' or `BACKUP TABLE'.  For `SELECT INTO ... OUTFILE',
  22559. the output file cannot already exist.  For `BACKUP TABLE', the same is
  22560. true as of MySQL 3.23.56 and 4.0.12, because this would be a security
  22561. risk.  See *Note `SELECT': SELECT and *Note `BACKUP TABLE': BACKUP
  22562. TABLE.
  22563.  
  22564. Another way to back up a database is to use the `mysqldump' program or
  22565. the `mysqlhotcopy script'.  See *Note `mysqldump': mysqldump and *Note
  22566. `mysqlhotcopy': mysqlhotcopy.
  22567.  
  22568.   1. Do a full backup of your database:
  22569.  
  22570.           shell> mysqldump --tab=/PATH/TO/SOME/DIR --opt DB_NAME
  22571.  
  22572.      Or:
  22573.  
  22574.           shell> mysqlhotcopy DB_NAME /PATH/TO/SOME/DIR
  22575.  
  22576.      You can also simply copy all table files (`*.frm', `*.MYD', and
  22577.      `*.MYI' files) as long as the server isn't updating anything.  The
  22578.      `mysqlhotcopy' script uses this method.  (But note that these
  22579.      methods will not work if your database contains `InnoDB' tables.
  22580.      `InnoDB' does not store table contents in database directories,
  22581.      and `mysqlhotcopy' works only for `MyISAM' and `ISAM' tables.)
  22582.  
  22583.   2. Stop `mysqld' if it's running, then start it with the
  22584.      `--log-bin[=file_name]' option.  *Note Binary log::. The binary
  22585.      log files provide you with the information you need to replicate
  22586.      changes to the database that are made subsequent to the point at
  22587.      which you executed `mysqldump'.
  22588.  
  22589. If your MySQL server is a slave replication server, then regardless of
  22590. the backup method you choose, you should also back up the `master.info'
  22591. and `relay-log.info' files when you back up your slave's data. These
  22592. files are always needed to resume replication after you restore the
  22593. slave's data. If your slave is subject to replicating `LOAD DATA
  22594. INFILE' commands, you should also back up any `SQL_LOAD-*' files that
  22595. may exist in the directory specified by the `--slave-load-tmpdir'
  22596. option. (This location defaults to the value of the `tmpdir' variable
  22597. if not specified.) The slave needs these files to resume replication of
  22598. any interrupted `LOAD DATA INFILE' operations.
  22599.  
  22600. If you have to restore `MyISAM' tables, try to recover them using
  22601. `REPAIR TABLE' or `myisamchk -r' first.  That should work in 99.9% of
  22602. all cases.  If `myisamchk' fails, try the following procedure.  Note
  22603. that it will work only if you have enabled binary logging by starting
  22604. MySQL with the `--log-bin' option; see *Note Binary log::.
  22605.  
  22606.   1. Restore the original `mysqldump' backup, or binary backup.
  22607.  
  22608.   2. Execute the following command to re-run the updates in the binary
  22609.      logs:
  22610.  
  22611.           shell> mysqlbinlog hostname-bin.[0-9]* | mysql
  22612.  
  22613.      In your case, you may want to re-run only certain binary logs, from
  22614.      certain positions (usually you want to re-run all binary logs from
  22615.      the date of the restored backup, excepting possibly some incorrect
  22616.      queries).  See *Note `mysqlbinlog': mysqlbinlog for more
  22617.      information on the `mysqlbinlog' utility and how to use it.
  22618.  
  22619.      If you are using the update logs instead, you can process their
  22620.      contents like this:
  22621.  
  22622.           shell> ls -1 -t -r hostname.[0-9]* | xargs cat | mysql
  22623.  
  22624.      `ls' is used to sort the update log filenames into the right order.
  22625.  
  22626.  
  22627. You can also do selective backups of individual files:
  22628.  
  22629.    * To dump the table, use `SELECT * INTO OUTFILE 'FILE_NAME' FROM
  22630.      TBL_NAME'.
  22631.  
  22632.    * To reload the table, use and restore with `LOAD DATA INFILE
  22633.      'file_name' REPLACE ...' To avoid duplicate records, the table
  22634.      must have a `PRIMARY KEY' or a `UNIQUE' index. The `REPLACE'
  22635.      keyword causes old records to be replaced with new ones when a new
  22636.      record duplicates an old record on a unique key value.
  22637.  
  22638.  
  22639. If you have performance problems with your server while making backups,
  22640. one strategy that can help is to set up replication and perform backups
  22641. on the slave rather than on the master.  *Note Replication Intro::.
  22642.  
  22643. If you are using a Veritas filesystem, you can make a backup like this:
  22644.  
  22645.   1. From a client program, execute `FLUSH TABLES WITH READ LOCK'.
  22646.  
  22647.   2. From another shell, execute `mount vxfs snapshot'.
  22648.  
  22649.   3. From the first client, execute `UNLOCK TABLES'.
  22650.  
  22651.   4. Copy files from the snapshot.
  22652.  
  22653.   5. Unmount the snapshot.
  22654.  
  22655. Table Maintenance and Crash Recovery
  22656. ------------------------------------
  22657.  
  22658. The following text discusses how to use `myisamchk' to check or repair
  22659. `MyISAM' tables (tables with `.MYI' and `.MYD' files).  The same
  22660. concepts apply to using `isamchk' to check or repair `ISAM' tables
  22661. (tables with `.ISM' and `.ISD' files).  *Note Table types::.
  22662.  
  22663. You can use the `myisamchk' utility to get information about your
  22664. database tables or to check, repair, or optimize them.  The following
  22665. sections describe how to invoke `myisamchk' (including a description of
  22666. its options), how to set up a table maintenance schedule, and how to
  22667. use `myisamchk' to perform its various functions.
  22668.  
  22669. Even though table repair with `myisamchk' is quite secure, it's always
  22670. a good idea to make a backup _before_ doing a repair (or any
  22671. maintenance operation that could make a lot of changes to a table)
  22672.  
  22673. `myisamchk' operations that affect indexes can cause `FULLTEXT' indexes
  22674. to be rebuilt with full-text parameters that are incompatible with the
  22675. values used by the MySQL server. To avoid this, read the instructions in
  22676. *Note `myisamchk' general options: myisamchk general options.
  22677.  
  22678. In many cases, you may find it simpler to do `MyISAM' table maintenance
  22679. using the SQL statements that perform operations that `myisamchk' can
  22680. do:
  22681.  
  22682.    * To check or repair `MyISAM' tables, use `CHECK TABLE' or `REPAIR
  22683.      TABLE'.
  22684.  
  22685.    * To optimize `MyISAM' tables, use `OPTIMIZE TABLE'.
  22686.  
  22687.    * To analyze `MyISAM' tables, use `ANALYZE TABLE'.
  22688.  
  22689.  
  22690. These statements were introduced in different versions, but all are
  22691. available from MySQL 3.23.14 on.  See *Note `ANALYZE TABLE': ANALYZE
  22692. TABLE, *Note `CHECK TABLE': CHECK TABLE, *Note `OPTIMIZE TABLE':
  22693. OPTIMIZE TABLE, and *Note `REPAIR TABLE': REPAIR TABLE.  The statements
  22694. can be used directly, or by means of the `mysqlcheck' client program,
  22695. which provides a command-line interface to them.
  22696.  
  22697. One advantage of these statements over `myisamchk' is that the server
  22698. does all the work. With `myisamchk', you must make sure that the server
  22699. does not use the tables at the same time. Otherwise, there can be
  22700. unwanted interaction betweeen `myisamchk' and the server.
  22701.  
  22702. `myisamchk' Invocation Syntax
  22703. .............................
  22704.  
  22705. Invoke `myisamchk' like this:
  22706.  
  22707.      shell> myisamchk [OPTIONS] TBL_NAME
  22708.  
  22709. The OPTIONS specify what you want `myisamchk' to do.  They are
  22710. described in the following sections.  You can also get a list of
  22711. options by invoking `myisamchk --help'.
  22712.  
  22713. With no options, `myisamchk' simply checks your table as the default
  22714. operation.  To get more information or to tell `myisamchk' to take
  22715. corrective action, specify options as described in the following
  22716. discussion.
  22717.  
  22718. TBL_NAME is the database table you want to check or repair.  If you run
  22719. `myisamchk' somewhere other than in the database directory, you must
  22720. specify the path to the database directory, because `myisamchk' has no
  22721. idea where the database is located.  In fact, `myisamchk' doesn't
  22722. actually care whether the files you are working on are located in a
  22723. database directory. You can copy the files that correspond to a
  22724. database table into some other location and perform recovery operations
  22725. on them there.
  22726.  
  22727. You can name several tables on the `myisamchk' command line if you
  22728. wish.  You can also specify a table by naming its index file (the file
  22729. with the `.MYI' suffix). This allows you to specify all tables in a
  22730. directory by using the pattern `*.MYI'.  For example, if you are in a
  22731. database directory, you can check all the `MyISAM' tables in that
  22732. directory like this:
  22733.  
  22734.      shell> myisamchk *.MYI
  22735.  
  22736. If you are not in the database directory, you can check all the tables
  22737. there by specifying the path to the directory:
  22738.  
  22739.      shell> myisamchk /path/to/database_dir/*.MYI
  22740.  
  22741. You can even check all tables in all databases by specifying a wildcard
  22742. with the path to the MySQL data directory:
  22743.  
  22744.      shell> myisamchk /path/to/datadir/*/*.MYI
  22745.  
  22746. The recommended way to quickly check all `MyISAM' and `ISAM' tables is:
  22747.  
  22748.      shell> myisamchk --silent --fast /path/to/datadir/*/*.MYI
  22749.      shell> isamchk --silent /path/to/datadir/*/*.ISM
  22750.  
  22751. If you want to check all `MyISAM' and `ISAM' tables and repair any that
  22752. are corrupted, you can use the following commands:
  22753.  
  22754.      shell> myisamchk --silent --force --fast --update-state \
  22755.                -O key_buffer=64M -O sort_buffer=64M \
  22756.                -O read_buffer=1M -O write_buffer=1M \
  22757.                /path/to/datadir/*/*.MYI
  22758.      shell> isamchk --silent --force -O key_buffer=64M \
  22759.                -O sort_buffer=64M -O read_buffer=1M -O write_buffer=1M \
  22760.                /path/to/datadir/*/*.ISM
  22761.  
  22762. These commands assume that you have more than 64MB free.  For more
  22763. information about memory allocation with `myisamchk', see *Note
  22764. myisamchk memory::.
  22765.  
  22766. You must ensure that no other program is using the tables while you are
  22767. running `myisamchk'.  Otherwise, when you run `myisamchk', it may
  22768. display the following error message:
  22769.  
  22770.      warning: clients are using or haven't closed the table properly
  22771.  
  22772. This means that you are trying to check a table that has been updated by
  22773. another program (such as the `mysqld' server) that hasn't yet closed
  22774. the file or that has died without closing the file properly.
  22775.  
  22776. If `mysqld' is running, you must force it to flush any table
  22777. modifications that are still buffered in memory by using `FLUSH
  22778. TABLES'. You should then ensure that no one is using the tables while
  22779. you are running `myisamchk'.  The easiest way to avoid this problem is
  22780. to use `CHECK TABLE' instead of `myisamchk' to check tables.
  22781.  
  22782. General Options for `myisamchk'
  22783. ...............................
  22784.  
  22785. The options described in this section can be used for any type of table
  22786. maintenance operation performed by `myisamchk'.  The sections following
  22787. this one describe options that pertain only to specific operations,
  22788. such as table checking or repairing.
  22789.  
  22790. `--help, -?'
  22791.      Display a help message and exit.
  22792.  
  22793. `--debug=DEBUG_OPTIONS, -# DEBUG_OPTIONS'
  22794.      Write a debugging log. The DEBUG_OPTIONS string often is
  22795.      `'d:t:o,FILE_NAME''.
  22796.  
  22797. `--silent, -s'
  22798.      Silent mode.  Write output only when errors occur. You can use `-s'
  22799.      twice (`-ss') to make `myisamchk' very silent.
  22800.  
  22801. `--verbose, -v'
  22802.      Verbose mode.  Print more information. This can be used with `-d'
  22803.      and `-e'. Use `-v' multiple times (`-vv', `-vvv') for even more
  22804.      output.
  22805.  
  22806. `--version, -V'
  22807.      Display version information and exit.
  22808.  
  22809. `--wait, -w'
  22810.      Instead of terminating with an error if the table is locked, wait
  22811.      until the table is unlocked before continuing.  Note that if you
  22812.      are running `mysqld' with the `--skip-external-locking' option,
  22813.      the table can be locked only by another `myisamchk' command.
  22814.  
  22815. You can also set the following variables by using `--VAR_NAME=VALUE'
  22816. options:
  22817.  
  22818. *Variable*                *Default Value*
  22819. `decode_bits'             9
  22820. `ft_max_word_len'         version-dependent
  22821. `ft_min_word_len'         4
  22822. `ft_stopword_file'        built-in list
  22823. `key_buffer_size'         523264
  22824. `myisam_block_size'       1024
  22825. `read_buffer_size'        262136
  22826. `sort_buffer_size'        2097144
  22827. `sort_key_blocks'         16
  22828. `write_buffer_size'       262136
  22829.  
  22830. It is also possible to set variables by using
  22831. `--set-variable=VAR_NAME=VALUE' or `-O VAR_NAME=VALUE' syntax. However,
  22832. this syntax is deprecated as of MySQL 4.0.
  22833.  
  22834. The possible `myisamchk' variables and their default values can be
  22835. examined with `myisamchk --help':
  22836.  
  22837. `sort_buffer_size' is used when the keys are repaired by sorting keys,
  22838. which is the normal case when you use `--recover'.
  22839.  
  22840. `key_buffer_size' is used when you are checking the table with
  22841. `--extend-check' or when the keys are repaired by inserting keys row by
  22842. row into the table (like when doing normal inserts). Repairing through
  22843. the key buffer is used in the following cases:
  22844.  
  22845.    * You use `--safe-recover'.
  22846.  
  22847.    * The temporary files needed to sort the keys would be more than
  22848.      twice as big as when creating the key file directly.  This is
  22849.      often the case when you have large key values for  `CHAR',
  22850.      `VARCHAR', or `TEXT' columns, because the sort operation needs to
  22851.      store the complete key values as it proceeds. If you have lots of
  22852.      temporary space and you can force `myisamchk' to repair by
  22853.      sorting, you can use the `--sort-recover' option.
  22854.  
  22855.  
  22856. Repairing through the key buffer takes much less disk space than using
  22857. sorting, but is also much slower.
  22858.  
  22859. If you want a faster repair, set the `key_buffer_size' and
  22860. `sort_buffer_size' variables to about 25% of your available memory.
  22861. You can set both variables to large values, because only one of them is
  22862. used at a time.
  22863.  
  22864. `myisam_block_size' is the size used for index blocks. It is available
  22865. as of MySQL 4.0.0.
  22866.  
  22867. The `ft_min_word_len' and `ft_max_word_len' variables are available as
  22868. of MySQL 4.0.0.  `ft_stopword_file' is available as of MySQL 4.0.19.
  22869.  
  22870. `ft_min_word_len' and `ft_max_word_len' indicate the minimum and
  22871. maximum word length for `FULLTEXT' indexes. `ft_stopword_file' names
  22872. the stopword file. These need to be set under the following
  22873. circumstances.
  22874.  
  22875. If you use `myisamchk' to perform an operation that modifies table
  22876. indexes (such as repair or analyze), the `FULLTEXT' indexes are rebuilt
  22877. using the default full-text parameter values for minimum and maximum
  22878. word length and the stopword file unless you specify otherwise.  This
  22879. can result in queries failing.
  22880.  
  22881. The problem occurs because these parameters are known only by the
  22882. server.  They are not stored in `MyISAM' index files.  To avoid the
  22883. problem if you have modified the minimum or maximum word length or the
  22884. stopword file in the server, specify the same `ft_min_word_len',
  22885. `ft_max_word_len', and `ft_stopword_file' values to `myisamchk' that
  22886. you use for `mysqld'. For example, if you have set the minimum word
  22887. length to 3, you can repair a table with `myisamchk' like this:
  22888.  
  22889.      shell> myisamchk --recover --ft_min_word_len=3 TBL_NAME.MYI
  22890.  
  22891. To ensure that `myisamchk' and the server use the same values for
  22892. full-text parameters, you can place each one in both the `[mysqld]' and
  22893. `[myisamchk]' sections of an option file:
  22894.  
  22895.      [mysqld]
  22896.      ft_min_word_len=3
  22897.      
  22898.      [myisamchk]
  22899.      ft_min_word_len=3
  22900.  
  22901. An alternative to using `myisamchk' is to use the `REPAIR TABLE',
  22902. `ANALYZE TABLE', `OPTIMIZE TABLE', or `ALTER TABLE'.  These statements
  22903. are performed by the server, which knows the proper full-text parameter
  22904. values to use.
  22905.  
  22906. Check Options for `myisamchk'
  22907. .............................
  22908.  
  22909. `myisamchk' supports the following options for table checking
  22910. operations:
  22911.  
  22912. `--check, -c'
  22913.      Check the table for errors. This is the default operation if you
  22914.      specify no option that selects an operation type explicitly.
  22915.  
  22916. `--check-only-changed, -C'
  22917.      Check only tables that have changed since the last check.
  22918.  
  22919. `--extend-check, -e'
  22920.      Check the table very thoroughly. This is quite slow if the table
  22921.      has many indexes.  This option should only be used in extreme
  22922.      cases.  Normally, `myisamchk' or `myisamchk --medium-check' should
  22923.      be able to determine whether there are any errors in the table.
  22924.  
  22925.      If you are using `--extend-check' and have plenty of memory,
  22926.      setting the `key_buffer_size' variable to a large value will help
  22927.      the repair operation run faster.
  22928.  
  22929. `--fast, -F'
  22930.      Check only tables that haven't been closed properly.
  22931.  
  22932. `--force, -f'
  22933.      Do a repair operation automatically if `myisamchk' finds any
  22934.      errors in the table.  The repair type is the same as that
  22935.      specified with the `--repair' or `-r' option.
  22936.  
  22937. `--information, -i'
  22938.      Print informational statistics about the table that is checked.
  22939.  
  22940. `--medium-check, -m'
  22941.      Do a check that is faster than an `--extend-check' operation.
  22942.      This finds only 99.99% of all errors, which should be good enough
  22943.      in most cases.
  22944.  
  22945. `--read-only, -T'
  22946.      Don't mark the table as checked. This is useful if you use
  22947.      `myisamchk' to check a table that is in use by some other
  22948.      application that doesn't use locking, such as `mysqld' when run
  22949.      with the `--skip-external-locking' option.
  22950.  
  22951. `--update-state, -U'
  22952.      Store information in the `.MYI' file to indicate when the table was
  22953.      checked and whether the table crashed.  This should be used to get
  22954.      full benefit of the `--check-only-changed' option, but you
  22955.      shouldn't use this option if the `mysqld' server is using the
  22956.      table and you are running it with the `--skip-external-locking'
  22957.      option.
  22958.  
  22959. Repair Options for `myisamchk'
  22960. ..............................
  22961.  
  22962. `myisamchk' supports the following options for table repair operations:
  22963.  
  22964. `--backup, -B'
  22965.      Make a backup of the `.MYD' file as `file_name-time.BAK'
  22966.  
  22967. `--character-sets-dir=PATH'
  22968.      The directory where character sets are installed.  *Note Character
  22969.      sets::.
  22970.  
  22971. `--correct-checksum'
  22972.      Correct the checksum information for the table.
  22973.  
  22974. `--data-file-length=#, -D #'
  22975.      Maximum length of the data file (when re-creating data file when
  22976.      it's "full").
  22977.  
  22978. `--extend-check, -e'
  22979.      Do a repair that tries to to recover every possible row from the
  22980.      data file.  Normally this will also find a lot of garbage rows.
  22981.      Don't use this option unless you are totally desperate.
  22982.  
  22983. `--force, -f'
  22984.      Overwrite old temporary files (files with names like
  22985.      `TBL_NAME.TMD') instead of aborting.
  22986.  
  22987. `--keys-used=#, -k #'
  22988.      For `myisamchk', the option value indicates which indexes to
  22989.      update.  Each binary bit of the option value corresponds to a
  22990.      table index, where the first index is bit 0.  For `isamchk', the
  22991.      option value indicates that only the first # of the table indexes
  22992.      should be updated.  In either case, an option value of 0 disables
  22993.      updates to all indexes, which can be used to get faster inserts.
  22994.      Deactivated indexes can be reactivated by using `myisamchk -r' or
  22995.      (`isamchk -r').
  22996.  
  22997. `--no-symlinks, -l'
  22998.      Do not follow symbolic links. Normally `myisamchk' repairs the
  22999.      table that a symlink points to.  This option doesn't exist as of
  23000.      MySQL 4.0, because versions from 4.0 on will not remove symlinks
  23001.      during repair operations.
  23002.  
  23003. `--parallel-recover, -p'
  23004.      Uses the same technique as `-r' and `-n', but creates all the keys
  23005.      in parallel, using different threads.  This option was added in
  23006.      MySQL 4.0.2.  _This is alpha code. Use at your own risk!_
  23007.  
  23008. `--quick, -q'
  23009.      Achieve a faster repair by not modifying the data file. You can
  23010.      specify this option twice to force `myisamchk' to modify the
  23011.      original data file in case of duplicate keys.
  23012.  
  23013. `--recover, -r'
  23014.      Do a repair that can fix almost any problem except unique keys
  23015.      that aren't unique (which is an extremely unlikely error with
  23016.      `ISAM'/`MyISAM' tables).  If you want to recover a table, this is
  23017.      the option to try first. You should try `-o' only if `myisamchk'
  23018.      reports that the table can't be recovered by `-r'.  (In the
  23019.      unlikely case that `-r' fails, the data file is still intact.)
  23020.  
  23021.      If you have lots of memory, you should increase the value of
  23022.      `sort_buffer_size'.
  23023.  
  23024. `--safe-recover, -o'
  23025.      Do a repair using an old recovery method that reads through all
  23026.      rows in order and updates all index trees based on the rows found.
  23027.      This is an order of magnitude slower than `-r', but can handle a
  23028.      couple of very unlikely cases that `-r' cannot.  This recovery
  23029.      method also uses much less disk space than `-r'. Normally, you
  23030.      should repair first with `-r', and then with `-o' only if `-r'
  23031.      fails.
  23032.  
  23033.      If you have lots of memory, you should increase the value of
  23034.      `key_buffer_size'.
  23035.  
  23036. `--set-character-set=NAME'
  23037.      Change the character set used by the table indexes.
  23038.  
  23039. `--sort-recover, -n'
  23040.      Force `myisamchk' to use sorting to resolve the keys even if the
  23041.      temporary files should be very big.
  23042.  
  23043. `--tmpdir=PATH, -t PATH'
  23044.      Path of the directory to be used for storing temporary files. If
  23045.      this is not set, `myisamchk' uses the value of the `TMPDIR'
  23046.      environment variable.  Starting from MySQL 4.1, `tmpdir' can be
  23047.      set to a list of directory paths that will be used successively in
  23048.      round-robin fashion for creating temporary files. The separator
  23049.      character between directory names should be colon (`:') on Unix
  23050.      and semicolon (`;') on Windows, NetWare, and OS/2.
  23051.  
  23052. `--unpack, -u'
  23053.      Unpack a table that was packed with `myisampack'.
  23054.  
  23055. Other Options for `myisamchk'
  23056. .............................
  23057.  
  23058. `myisamchk' supports the following options for actions other than table
  23059. checks and repairs:
  23060.  
  23061. `--analyze, -a'
  23062.      Analyze the distribution of keys. This improves join performance
  23063.      by enabling the join optimizer to better choose the order in which
  23064.      to join the tables and which keys it should use. To obtain
  23065.      information about the distribution, use a `myisamchk --description
  23066.      --verbose TBL_NAME' command or the `SHOW KEYS FROM TBL_NAME'
  23067.      statement.
  23068.  
  23069. `--description, -d'
  23070.      Print some descriptive information about the table.
  23071.  
  23072. `--set-auto-increment[=VALUE], -A[VALUE]'
  23073.      Force `AUTO_INCREMENT' numbering for new records to start at the
  23074.      given value (or higher, if there are already records with
  23075.      `AUTO_INCREMENT' values this large). If VALUE is not specified,
  23076.      `AUTO_INCREMENT' number for new records begins with the largest
  23077.      value currently in the table, plus one.
  23078.  
  23079. `--sort-index, -S'
  23080.      Sort the index tree blocks in high-low order.  This optimizes
  23081.      seeks and makes table scanning by key faster.
  23082.  
  23083. `--sort-records=#, -R #'
  23084.      Sort records according to a particular index.  This makes your
  23085.      data much more localized and may speed up range-based `SELECT' and
  23086.      `ORDER BY' operations that use this index. (The first time you use
  23087.      this option to sort a table, it may be very slow.) To determine a
  23088.      table's index numbers, use `SHOW KEYS', which displays a table's
  23089.      indexes in the same order that `myisamchk' sees them.  Indexes are
  23090.      numbered beginning with 1.
  23091.  
  23092. `myisamchk' Memory Usage
  23093. ........................
  23094.  
  23095. Memory allocation is important when you run `myisamchk'.  `myisamchk'
  23096. uses no more memory than you specify with the `-O' options.  If you are
  23097. going to use `myisamchk' on very large tables, you should first decide
  23098. how much memory you want it to use.  The default is to use only about
  23099. 3MB to perform repairs.  By using larger values, you can get
  23100. `myisamchk' to operate faster.  For example, if you have more than 32MB
  23101. RAM, you could use options such as these (in addition to any other
  23102. options you might specify):
  23103.  
  23104.      shell> myisamchk -O sort=16M -O key=16M -O read=1M -O write=1M ...
  23105.  
  23106. Using `-O sort=16M' should probably be enough for most cases.
  23107.  
  23108. Be aware that `myisamchk' uses temporary files in `TMPDIR'. If `TMPDIR'
  23109. points to a memory filesystem, you may easily get out of memory errors.
  23110. If this happens, set `TMPDIR' to point at some directory located on a
  23111. filesystem with more space and run `myisamchk' again.
  23112.  
  23113. When repairing, `myisamchk' will also need a lot of disk space:
  23114.  
  23115.    * Double the size of the data file (the original one and a copy).
  23116.      This space is not needed if you do a repair with `--quick'; in this
  23117.      case, only the index file is re-created.  This space is needed on
  23118.      the same filesystem as the original data file! (The copy is
  23119.      created in the same directory as the original.)
  23120.  
  23121.    * Space for the new index file that replaces the old one. The old
  23122.      index file is truncated at the start of the repair operation, so
  23123.      you usually ignore this space.  This space is needed on the same
  23124.      filesystem as the original index file!
  23125.  
  23126.    * When using `--recover' or `--sort-recover' (but not when using
  23127.      `--safe-recover'), you will need space for a sort buffer. The
  23128.      amount of space required is:
  23129.  
  23130.           (LARGEST_KEY + ROW_POINTER_LENGTH) * NUMBER_OF_ROWS * 2
  23131.  
  23132.      You can check the length of the keys and the `row_pointer_length'
  23133.      with `myisamchk -dv TBL_NAME'.  This space is allocated in the
  23134.      temporary directory (specified by `TMPDIR' or `--tmpdir=PATH').
  23135.  
  23136.  
  23137. If you have a problem with disk space during repair, you can try to use
  23138. `--safe-recover' instead of `--recover'.
  23139.  
  23140. Using `myisamchk' for Crash Recovery
  23141. ....................................
  23142.  
  23143. If you run `mysqld' with `--skip-external-locking' (which is the
  23144. default on some systems, such as Linux), you can't reliably use
  23145. `myisamchk' to check a table when `mysqld' is using the same table.  If
  23146. you can be sure that no one is accessing the tables through `mysqld'
  23147. while you run `myisamchk', you only have to do `mysqladmin
  23148. flush-tables' before you start checking the tables.  If you can't
  23149. guarantee this, then you must stop `mysqld' while you check the tables.
  23150. If you run `myisamchk' while `mysqld' is updating the tables, you may
  23151. get a warning that a table is corrupt even when it isn't.
  23152.  
  23153. If you are not using `--skip-external-locking', you can use `myisamchk'
  23154. to check tables at any time.  While you do this, all clients that try
  23155. to update the table will wait until `myisamchk' is ready before
  23156. continuing.
  23157.  
  23158. If you use `myisamchk' to repair or optimize tables, you _must_ always
  23159. ensure that the `mysqld' server is not using the table (this also
  23160. applies if you are using `--skip-external-locking').  If you don't take
  23161. down `mysqld', you should at least do a `mysqladmin flush-tables'
  23162. before you run `myisamchk'.  Your tables _may become corrupted_ if the
  23163. server and `myisamchk' access the tables simultaneously.
  23164.  
  23165. This section describes how to check for and deal with data corruption
  23166. in MySQL databases.  If your tables get corrupted frequently you should
  23167. try to find the reason why.  *Note Crashing::.
  23168.  
  23169. The `MyISAM' table section contains reason for why a table could be
  23170. corrupted. *Note `MyISAM' table problems: MyISAM table problems.
  23171.  
  23172. When performing crash recovery, it is important to understand that each
  23173. `MyISAM' table TBL_NAME in a database corresponds to three files in the
  23174. database directory:
  23175.  
  23176. *File*         *Purpose*
  23177. `TBL_NAME.frm' Definition (format) file
  23178. `TBL_NAME.MYD' Data file
  23179. `TBL_NAME.MYI' Index file
  23180.  
  23181. Each of these three file types is subject to corruption in various
  23182. ways, but problems occur most often in data files and index files.
  23183.  
  23184. `myisamchk' works by creating a copy of the `.MYD' data file row by
  23185. row. It ends the repair stage by removing the old `.MYD' file and
  23186. renaming the new file to the original file name.  If you use `--quick',
  23187. `myisamchk' does not create a temporary `.MYD' file, but instead
  23188. assumes that the `.MYD' file is correct and only generates a new index
  23189. file without touching the `.MYD' file. This is safe, because
  23190. `myisamchk' automatically detects whether the `.MYD' file is corrupt
  23191. and aborts the repair if it is.  You can also specify the `--quick'
  23192. option twice to `myisamchk'.  In this case, `myisamchk' does not abort
  23193. on some errors (such as duplicate-key errors) but instead tries to
  23194. resolve them by modifying the `.MYD' file. Normally the use of two
  23195. `--quick' options is useful only if you have too little free disk space
  23196. to perform a normal repair.  In this case, you should at least make a
  23197. backup before running `myisamchk'.
  23198.  
  23199. How to Check `MyISAM' Tables for Errors
  23200. .......................................
  23201.  
  23202. To check a `MyISAM' table, use the following commands:
  23203.  
  23204. `myisamchk TBL_NAME'
  23205.      This finds 99.99% of all errors. What it can't find is corruption
  23206.      that involves _only_ the data file (which is very unusual). If you
  23207.      want to check a table, you should normally run `myisamchk' without
  23208.      options or with either the `-s' or `--silent' option.
  23209.  
  23210. `myisamchk -m TBL_NAME'
  23211.      This finds 99.999% of all errors. It first checks all index
  23212.      entries for errors and then reads through all rows. It calculates
  23213.      a checksum for all keys in the rows and verifies that the checksum
  23214.      matches the checksum for the keys in the index tree.
  23215.  
  23216. `myisamchk -e TBL_NAME'
  23217.      This does a complete and thorough check of all data (`-e' means
  23218.      "extended check"). It does a check-read of every key for each row
  23219.      to verify that they indeed point to the correct row.  This may
  23220.      take a long time for a large table that has many indexes.
  23221.      Normally, `myisamchk' stops after the first error it finds. If you
  23222.      want to obtain more information, you can add the `--verbose'
  23223.      (`-v') option.  This causes `myisamchk' to keep going, up through
  23224.      a maximum of 20 errors.
  23225.  
  23226. `myisamchk -e -i TBL_NAME'
  23227.      Like the previous command, but the `-i' option tells `myisamchk' to
  23228.      print some informational statistics, too.
  23229.  
  23230. In most cases, a simple `myisamchk' with no arguments other than the
  23231. table name is sufficient to check a table.
  23232.  
  23233. How to Repair Tables
  23234. ....................
  23235.  
  23236. The discussion in this section describes how to use `myisamchk' on
  23237. `MyISAM' tables (extensions `.MYI' and `.MYD').  If you are using
  23238. `ISAM' tables (extensions `.ISM' and `.ISD'), you should use `isamchk'
  23239. instead; the concepts are similar.
  23240.  
  23241. If you are using MySQL 3.23.16 and above, you can (and should) use the
  23242. `CHECK TABLE' and `REPAIR TABLE' statements to check and repair
  23243. `MyISAM' tables.  See *Note `CHECK TABLE': CHECK TABLE and *Note
  23244. `REPAIR TABLE': REPAIR TABLE.
  23245.  
  23246. The symptoms of a corrupted table include queries that abort
  23247. unexpectedly and observable errors such as these:
  23248.  
  23249.    * `TBL_NAME.frm' is locked against change
  23250.  
  23251.    * Can't find file `TBL_NAME.MYI' (Errcode: ###)
  23252.  
  23253.    * Unexpected end of file
  23254.  
  23255.    * Record file is crashed
  23256.  
  23257.    * Got error ### from table handler
  23258.  
  23259. To get more information about the error you can run `perror' ###, where
  23260. ### is the error number. The following example shows how to use
  23261. `perror' to find the meanings for the most common error numbers that
  23262. indicate a problem with a table:
  23263.  
  23264.      shell> perror 126 127 132 134 135 136 141 144 145
  23265.      126 = Index file is crashed / Wrong file format
  23266.      127 = Record-file is crashed
  23267.      132 = Old database file
  23268.      134 = Record was already deleted (or record file crashed)
  23269.      135 = No more room in record file
  23270.      136 = No more room in index file
  23271.      141 = Duplicate unique key or constraint on write or update
  23272.      144 = Table is crashed and last repair failed
  23273.      145 = Table was marked as crashed and should be repaired
  23274.  
  23275. Note that error 135 (no more room in record file) and error 136 (no more
  23276. room in index file) are not errors that can be fixed by a simple
  23277. repair. In this case, you have to use `ALTER TABLE' to increase the
  23278. `MAX_ROWS' and `AVG_ROW_LENGTH' table option values:
  23279.  
  23280.      ALTER TABLE TBL_NAME MAX_ROWS=XXX AVG_ROW_LENGTH=YYY;
  23281.  
  23282. If you don't know the current table option values, use `SHOW CREATE
  23283. TABLE tbl_name'.
  23284.  
  23285. For the other errors, you must repair your tables. `myisamchk' can
  23286. usually detect and fix most problems that occur.
  23287.  
  23288. The repair process involves up to four stages, described here. Before
  23289. you begin, you should change location to the database directory and
  23290. check the permissions of the table files. On Unix, make sure that they
  23291. are readable by the user that `mysqld' runs as (and to you, because you
  23292. need to access the files you are checking).  If it turns out you need
  23293. to modify files, they must also be writable by you.
  23294.  
  23295. The options that you can use for table maintenance with `myisamchk' and
  23296. `isamchk' are described in several of the earlier subsections of *Note
  23297. Table maintenance::.
  23298.  
  23299. The following section is for the cases where the above command fails or
  23300. if you want to use the extended features that `myisamchk' and `isamchk'
  23301. provide.
  23302.  
  23303. If you are going to repair a table from the command line, you must first
  23304. stop the `mysqld' server. Note that when you do `mysqladmin shutdown'
  23305. on a remote server, the `mysqld' server will still be alive for a while
  23306. after `mysqladmin' returns, until all queries are stopped and all keys
  23307. have been flushed to disk.
  23308.  
  23309. *Stage 1: Checking your tables*
  23310.  
  23311. Run `myisamchk *.MYI' or `myisamchk -e *.MYI' if you have more time.
  23312. Use the `-s' (silent) option to suppress unnecessary information.
  23313.  
  23314. If the `mysqld' server is down, you should use the `--update-state'
  23315. option to tell `myisamchk' to mark the table as 'checked'.
  23316.  
  23317. You have to repair only those tables for which `myisamchk' announces an
  23318. error.  For such tables, proceed to Stage 2.
  23319.  
  23320. If you get weird errors when checking (such as `out of memory' errors),
  23321. or if `myisamchk' crashes, go to Stage 3.
  23322.  
  23323. *Stage 2: Easy safe repair*
  23324.  
  23325. Note: If you want a repair operation to go much faster, you should set
  23326. the values of the `sort_buffer_size' and `key_buffer_size' variables
  23327. each to about 25% of your available memory when running `myisamchk' or
  23328. `isamchk'.
  23329.  
  23330. First, try `myisamchk -r -q TBL_NAME' (`-r -q' means "quick recovery
  23331. mode"). This will attempt to repair the index file without touching the
  23332. data file.  If the data file contains everything that it should and the
  23333. delete links point at the correct locations within the data file, this
  23334. should work, and the table is fixed. Start repairing the next table.
  23335. Otherwise, use the following procedure:
  23336.  
  23337.   1. Make a backup of the data file before continuing.
  23338.  
  23339.   2. Use `myisamchk -r TBL_NAME' (`-r' means "recovery mode"). This will
  23340.      remove incorrect records and deleted records from the data file and
  23341.      reconstruct the index file.
  23342.  
  23343.   3. If the preceding step fails, use `myisamchk --safe-recover
  23344.      TBL_NAME'.  Safe recovery mode uses an old recovery method that
  23345.      handles a few cases that regular recovery mode doesn't (but is
  23346.      slower).
  23347.  
  23348. If you get weird errors when repairing (such as `out of memory'
  23349. errors), or if `myisamchk' crashes, go to Stage 3.
  23350.  
  23351. *Stage 3: Difficult repair*
  23352.  
  23353. You should reach this stage only if the first 16KB block in the index
  23354. file is destroyed or contains incorrect information, or if the index
  23355. file is missing.  In this case, it's necessary to create a new index
  23356. file. Do so as follows:
  23357.  
  23358.   1. Move the data file to some safe place.
  23359.  
  23360.   2. Use the table description file to create new (empty) data and
  23361.      index files:
  23362.  
  23363.           shell> mysql DB_NAME
  23364.           mysql> SET AUTOCOMMIT=1;
  23365.           mysql> TRUNCATE TABLE TBL_NAME;
  23366.           mysql> quit
  23367.  
  23368.      If your version of MySQL doesn't have `TRUNCATE TABLE', use
  23369.      `DELETE FROM TBL_NAME' instead.
  23370.  
  23371.   3. Copy the old data file back onto the newly created data file.
  23372.      (Don't just move the old file back onto the new file; you want to
  23373.      retain a copy in case something goes wrong.)
  23374.  
  23375. Go back to Stage 2.  `myisamchk -r -q' should work now.  (This shouldn't
  23376. be an endless loop.)
  23377.  
  23378. As of MySQL 4.0.2, you can also use `REPAIR TABLE TBL_NAME USE_FRM',
  23379. which performs the whole procedure automatically.
  23380.  
  23381. *Stage 4: Very difficult repair*
  23382.  
  23383. You should reach this stage only if the `.frm' description file has also
  23384. crashed. That should never happen, because the description file isn't
  23385. changed after the table is created:
  23386.  
  23387.   1. Restore the description file from a backup and go back to Stage 3.
  23388.      You can also restore the index file and go back to Stage 2.  In
  23389.      the latter case, you should start with `myisamchk -r'.
  23390.  
  23391.   2. If you don't have a backup but know exactly how the table was
  23392.      created, create a copy of the table in another database.  Remove
  23393.      the new data file, then move the `.frm' description and `.MYI'
  23394.      index files from the other database to your crashed database.
  23395.      This gives you new description and index files, but leaves the
  23396.      `.MYD' data file alone.  Go back to Stage 2 and attempt to
  23397.      reconstruct the index file.
  23398.  
  23399.  
  23400. Table Optimization
  23401. ..................
  23402.  
  23403. To coalesce fragmented records and eliminate wasted space resulting from
  23404. deleting or updating records, run `myisamchk' in recovery mode:
  23405.  
  23406.      shell> myisamchk -r TBL_NAME
  23407.  
  23408. You can optimize a table in the same way by using the SQL `OPTIMIZE
  23409. TABLE' statement.  `OPTIMIZE TABLE' does a repair of the table and a key
  23410. analysis, and also sorts the index tree to give faster key lookups.
  23411. There is also no possibility of unwanted interaction between a utility
  23412. and the server, because the server does all the work when you use
  23413. `OPTIMIZE TABLE'. *Note `OPTIMIZE TABLE': OPTIMIZE TABLE.
  23414.  
  23415. `myisamchk' also has a number of other options you can use to improve
  23416. the performance of a table:
  23417.  
  23418.    * `-S', `--sort-index'
  23419.  
  23420.    * `-R INDEX_NUM', `--sort-records=INDEX_NUM'
  23421.  
  23422.    * `-a', `--analyze'
  23423.  
  23424. For a full description of the options, see *Note myisamchk syntax::.
  23425.  
  23426. Setting Up a Table Maintenance Schedule
  23427. ---------------------------------------
  23428.  
  23429. It is a good idea to perform table checks on a regular basis rather than
  23430. waiting for problems to occur.  One way to check and repair `MyISAM'
  23431. tables is with the `CHECK TABLE' and `REPAIR TABLE' statements.  These
  23432. are available starting with MySQL 3.23.16.  See *Note `CHECK TABLE':
  23433. CHECK TABLE and *Note `REPAIR TABLE': REPAIR TABLE.
  23434.  
  23435. Another way to check tables is to use `myisamchk'.  For maintenance
  23436. purposes, you can use `myisamchk -s'.  The `-s' option (short for
  23437. `--silent') causes `myisamchk' to run in silent mode, printing messages
  23438. only when errors occur.
  23439.  
  23440. It's also a good idea to check tables when the server starts.  For
  23441. example, whenever the machine has done a restart in the middle of an
  23442. update, you usually need to check all the tables that could have been
  23443. affected. (These are "expected crashed tables.")  To check `MyISAM'
  23444. tables automatically, start the server with the `--myisam-recover'
  23445. option, available as of MySQL 3.23.25.  If your server is too old to
  23446. support this option, you could add a test to `mysqld_safe' that runs
  23447. `myisamchk' to check all tables that have been modified during the last
  23448. 24 hours if there is an old `.pid' (process ID) file left after a
  23449. restart.  (The `.pid' file is created by `mysqld' when it starts and
  23450. removed when it terminates normally.  The presence of a `.pid' file at
  23451. system startup time indicates that `mysqld' terminated abnormally.)
  23452.  
  23453. An even better test would be to check any table whose last-modified time
  23454. is more recent than that of the `.pid' file.
  23455.  
  23456. You should also check your tables regularly during normal system
  23457. operation.  At MySQL AB, we run a `cron' job to check all our important
  23458. tables once a week, using a line like this in a `crontab' file:
  23459.  
  23460.      35 0 * * 0 /path/to/myisamchk --fast --silent /path/to/datadir/*/*.MYI
  23461.  
  23462. This prints out information about crashed tables so that we can examine
  23463. and repair them when needed.
  23464.  
  23465. Because we haven't had any unexpectedly crashed tables (tables that
  23466. become corrupted for reasons other than hardware trouble) for a couple
  23467. of years now (this is really true), once a week is more than enough for
  23468. us.
  23469.  
  23470. We recommend that to start with, you execute `myisamchk -s' each night
  23471. on all tables that have been updated during the last 24 hours, until
  23472. you come to trust MySQL as much as we do.
  23473.  
  23474. Normally, MySQL tables need little maintenance.  If you are changing
  23475. `MyISAM' tables with dynamic-sized rows (tables with `VARCHAR', `BLOB',
  23476. or `TEXT' columns) or have tables with many deleted rows you may want
  23477. to defragment/reclaim space from the tables from time to time (once a
  23478. month?).
  23479.  
  23480. You can do this by using `OPTIMIZE TABLE' on the tables in question.
  23481. Or, if you can stop the `mysqld' server for a while, change location
  23482. into the data directory and use this command while the server is
  23483. stopped:
  23484.  
  23485.      shell> myisamchk -r -s --sort-index -O sort_buffer_size=16M */*.MYI
  23486.  
  23487. For `ISAM' tables, the command is similar:
  23488.  
  23489.      shell> isamchk -r -s --sort-index -O sort_buffer_size=16M */*.MYI
  23490.  
  23491. Getting Information About a Table
  23492. ---------------------------------
  23493.  
  23494. To obtain a description of a table or statistics about it, use the
  23495. commands shown here. We explain some of the information in more detail
  23496. later:
  23497.  
  23498.    * `myisamchk -d TBL_NAME'
  23499.  
  23500.      Runs `myisamchk' in "describe mode" to produce a description of
  23501.      your table. If you start the MySQL server using the
  23502.      `--skip-external-locking' option, `myisamchk' may report an error
  23503.      for a table that is updated while it runs.  However, because
  23504.      `myisamchk' doesn't change the table in describe mode, there is no
  23505.      risk of destroying data.
  23506.  
  23507.    * `myisamchk -d -v TBL_NAME'
  23508.  
  23509.      Adding `-v' runs `myisamchk' in verbose mode so that it produces
  23510.      more information about what it is doing.
  23511.  
  23512.    * `myisamchk -eis TBL_NAME'
  23513.  
  23514.      Shows only the most important information from a table. This
  23515.      operation is slow because it must read the entire table.
  23516.  
  23517.    * `myisamchk -eiv TBL_NAME'
  23518.  
  23519.      This is like `-eis', but tells you what is being done.
  23520.  
  23521.  
  23522. Sample output for some of these commands follows. They are based on a
  23523. table with these data and index file sizes:
  23524.  
  23525.      -rw-rw-r--   1 monty    tcx     317235748 Jan 12 17:30 company.MYD
  23526.      -rw-rw-r--   1 davida   tcx      96482304 Jan 12 18:35 company.MYM
  23527.  
  23528. Example of `myisamchk -d' output:
  23529.  
  23530.      MyISAM file:     company.MYI
  23531.      Record format:   Fixed length
  23532.      Data records:    1403698  Deleted blocks:         0
  23533.      Recordlength:    226
  23534.      
  23535.      table description:
  23536.      Key Start Len Index   Type
  23537.      1   2     8   unique  double
  23538.      2   15    10  multip. text packed stripped
  23539.      3   219   8   multip. double
  23540.      4   63    10  multip. text packed stripped
  23541.      5   167   2   multip. unsigned short
  23542.      6   177   4   multip. unsigned long
  23543.      7   155   4   multip. text
  23544.      8   138   4   multip. unsigned long
  23545.      9   177   4   multip. unsigned long
  23546.          193   1           text
  23547.  
  23548. Example of `myisamchk -d -v' output:
  23549.  
  23550.      MyISAM file:         company
  23551.      Record format:       Fixed length
  23552.      File-version:        1
  23553.      Creation time:       1999-10-30 12:12:51
  23554.      Recover time:        1999-10-31 19:13:01
  23555.      Status:              checked
  23556.      Data records:            1403698  Deleted blocks:              0
  23557.      Datafile parts:          1403698  Deleted data:                0
  23558.      Datafile pointer (bytes):      3  Keyfile pointer (bytes):     3
  23559.      Max datafile length:  3791650815  Max keyfile length: 4294967294
  23560.      Recordlength:                226
  23561.      
  23562.      table description:
  23563.      Key Start Len Index   Type                  Rec/key     Root Blocksize
  23564.      1   2     8   unique  double                      1 15845376      1024
  23565.      2   15    10  multip. text packed stripped        2 25062400      1024
  23566.      3   219   8   multip. double                     73 40907776      1024
  23567.      4   63    10  multip. text packed stripped        5 48097280      1024
  23568.      5   167   2   multip. unsigned short           4840 55200768      1024
  23569.      6   177   4   multip. unsigned long            1346 65145856      1024
  23570.      7   155   4   multip. text                     4995 75090944      1024
  23571.      8   138   4   multip. unsigned long              87 85036032      1024
  23572.      9   177   4   multip. unsigned long             178 96481280      1024
  23573.          193   1           text
  23574.  
  23575. Example of `myisamchk -eis' output:
  23576.  
  23577.      Checking MyISAM file: company
  23578.      Key:  1:  Keyblocks used:  97%  Packed:    0%  Max levels:  4
  23579.      Key:  2:  Keyblocks used:  98%  Packed:   50%  Max levels:  4
  23580.      Key:  3:  Keyblocks used:  97%  Packed:    0%  Max levels:  4
  23581.      Key:  4:  Keyblocks used:  99%  Packed:   60%  Max levels:  3
  23582.      Key:  5:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  23583.      Key:  6:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  23584.      Key:  7:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  23585.      Key:  8:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  23586.      Key:  9:  Keyblocks used:  98%  Packed:    0%  Max levels:  4
  23587.      Total:    Keyblocks used:  98%  Packed:   17%
  23588.      
  23589.      Records:          1403698    M.recordlength:     226
  23590.      Packed:             0%
  23591.      Recordspace used:     100%   Empty space:          0%
  23592.      Blocks/Record:   1.00
  23593.      Record blocks:    1403698    Delete blocks:        0
  23594.      Recorddata:     317235748    Deleted data:         0
  23595.      Lost space:             0    Linkdata:             0
  23596.      
  23597.      User time 1626.51, System time 232.36
  23598.      Maximum resident set size 0, Integral resident set size 0
  23599.      Non physical pagefaults 0, Physical pagefaults 627, Swaps 0
  23600.      Blocks in 0 out 0, Messages in 0 out 0, Signals 0
  23601.      Voluntary context switches 639, Involuntary context switches 28966
  23602.  
  23603. Example of `myisamchk -eiv' output:
  23604.  
  23605.      Checking MyISAM file: company
  23606.      Data records: 1403698   Deleted blocks:       0
  23607.      - check file-size
  23608.      - check delete-chain
  23609.      block_size 1024:
  23610.      index  1:
  23611.      index  2:
  23612.      index  3:
  23613.      index  4:
  23614.      index  5:
  23615.      index  6:
  23616.      index  7:
  23617.      index  8:
  23618.      index  9:
  23619.      No recordlinks
  23620.      - check index reference
  23621.      - check data record references index: 1
  23622.      Key:  1:  Keyblocks used:  97%  Packed:    0%  Max levels:  4
  23623.      - check data record references index: 2
  23624.      Key:  2:  Keyblocks used:  98%  Packed:   50%  Max levels:  4
  23625.      - check data record references index: 3
  23626.      Key:  3:  Keyblocks used:  97%  Packed:    0%  Max levels:  4
  23627.      - check data record references index: 4
  23628.      Key:  4:  Keyblocks used:  99%  Packed:   60%  Max levels:  3
  23629.      - check data record references index: 5
  23630.      Key:  5:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  23631.      - check data record references index: 6
  23632.      Key:  6:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  23633.      - check data record references index: 7
  23634.      Key:  7:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  23635.      - check data record references index: 8
  23636.      Key:  8:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  23637.      - check data record references index: 9
  23638.      Key:  9:  Keyblocks used:  98%  Packed:    0%  Max levels:  4
  23639.      Total:    Keyblocks used:   9%  Packed:   17%
  23640.      
  23641.      - check records and index references
  23642.      [LOTS OF ROW NUMBERS DELETED]
  23643.      
  23644.      Records:         1403698   M.recordlength:   226   Packed:           0%
  23645.      Recordspace used:    100%  Empty space:        0%  Blocks/Record: 1.00
  23646.      Record blocks:   1403698   Delete blocks:      0
  23647.      Recorddata:    317235748   Deleted data:       0
  23648.      Lost space:            0   Linkdata:           0
  23649.      
  23650.      User time 1639.63, System time 251.61
  23651.      Maximum resident set size 0, Integral resident set size 0
  23652.      Non physical pagefaults 0, Physical pagefaults 10580, Swaps 0
  23653.      Blocks in 4 out 0, Messages in 0 out 0, Signals 0
  23654.      Voluntary context switches 10604, Involuntary context switches 122798
  23655.  
  23656. Explanations for the types of information `myisamchk' produces are
  23657. given here.  "Keyfile" refers to the index file.  "Record" and "row"
  23658. are synonymous.
  23659.  
  23660.    * `MyISAM file'
  23661.  
  23662.      Name of the `MyISAM' (index) file.
  23663.  
  23664.    * `File-version'
  23665.  
  23666.      Version of `MyISAM' format. Currently always 2.
  23667.  
  23668.    * `Creation time'
  23669.  
  23670.      When the data file was created.
  23671.  
  23672.    * `Recover time'
  23673.  
  23674.      When the index/data file was last reconstructed.
  23675.  
  23676.    * `Data records'
  23677.  
  23678.      How many records are in the table.
  23679.  
  23680.    * `Deleted blocks'
  23681.  
  23682.      How many deleted blocks still have reserved space.  You can
  23683.      optimize your table to minimize this space.  *Note Optimization::.
  23684.  
  23685.    * `Datafile parts'
  23686.  
  23687.      For dynamic record format, this indicates how many data blocks
  23688.      there are. For an optimized table without fragmented records, this
  23689.      is the same as `Data records'.
  23690.  
  23691.    * `Deleted data'
  23692.  
  23693.      How many bytes of unreclaimed deleted data there are.  You can
  23694.      optimize your table to minimize this space.  *Note Optimization::.
  23695.  
  23696.    * `Datafile pointer'
  23697.  
  23698.      The size of the data file pointer, in bytes. It is usually 2, 3,
  23699.      4, or 5 bytes. Most tables manage with 2 bytes, but this cannot be
  23700.      controlled from MySQL yet. For fixed tables, this is a record
  23701.      address. For dynamic tables, this is a byte address.
  23702.  
  23703.    * `Keyfile pointer'
  23704.  
  23705.      The size of the index file pointer, in bytes. It is usually 1, 2,
  23706.      or 3 bytes. Most tables manage with 2 bytes, but this is calculated
  23707.      automatically by MySQL. It is always a block address.
  23708.  
  23709.    * `Max datafile length'
  23710.  
  23711.      How long the table data file can become, in bytes.
  23712.  
  23713.    * `Max keyfile length'
  23714.  
  23715.      How long the table index file can become, in bytes.
  23716.  
  23717.    * `Recordlength'
  23718.  
  23719.      How much space each record takes, in bytes.
  23720.  
  23721.    * `Record format'
  23722.  
  23723.      The format used to store table rows.  The preceding examples use
  23724.      `Fixed length'.  Other possible values are `Compressed' and
  23725.      `Packed'.
  23726.  
  23727.    * `table description'
  23728.  
  23729.      A list of all keys in the table. For each key, `myisamchk' displays
  23730.      some low-level information:
  23731.  
  23732.         - `Key'
  23733.  
  23734.           This key's number.
  23735.  
  23736.         - `Start'
  23737.  
  23738.           Where in the record this index part starts.
  23739.  
  23740.         - `Len'
  23741.  
  23742.           How long this index part is. For packed numbers, this should
  23743.           always be the full length of the column. For strings, it may
  23744.           be shorter than the full length of the indexed column,
  23745.           because you can index a prefix of a string column.
  23746.  
  23747.         - `Index'
  23748.  
  23749.           Whether a key value can exist multiple times in the index.
  23750.           Values are `unique' or `multip.' (multiple).
  23751.  
  23752.         - `Type'
  23753.  
  23754.           What data type this index part has. This is a `MyISAM' data
  23755.           type with the options `packed', `stripped', or `empty'.
  23756.  
  23757.         - `Root'
  23758.  
  23759.           Address of the root index block.
  23760.  
  23761.         - `Blocksize'
  23762.  
  23763.           The size of each index block. By default this is 1024, but
  23764.           the value may be changed at compile time when MySQL is built
  23765.           from source.
  23766.  
  23767.         - `Rec/key'
  23768.  
  23769.           This is a statistical value used by the optimizer. It tells
  23770.           how many records there are per value for this key. A unique
  23771.           key always has a value of 1. This may be updated after a
  23772.           table is loaded (or greatly changed) with `myisamchk -a'. If
  23773.           this is not updated at all, a default value of 30 is given.
  23774.  
  23775.      For the table shown in the examples, there are two `table
  23776.      description' lines for the ninth index. This indicates that it is
  23777.      a multiple-part index with two parts.
  23778.  
  23779.    * `Keyblocks used'
  23780.  
  23781.      What percentage of the keyblocks are used. When a table has just
  23782.      been reorganized with `myisamchk', as for the table in the
  23783.      examples, the values are very high (very near the theoretical
  23784.      maximum).
  23785.  
  23786.    * `Packed'
  23787.  
  23788.      MySQL tries to pack keys with a common suffix. This can only be
  23789.      used for indexes on `CHAR', `VARCHAR', or `DECIMAL' columns. For
  23790.      long indexed strings that have similar leftmost parts, this can
  23791.      significantly reduce the space used. In the third example above,
  23792.      the fourth key is 10 characters long and a 60% reduction in space
  23793.      is achieved.
  23794.  
  23795.    * `Max levels'
  23796.  
  23797.      How deep the B-tree for this key is. Large tables with long key
  23798.      values get high values.
  23799.  
  23800.    * `Records'
  23801.  
  23802.      How many rows are in the table.
  23803.  
  23804.    * `M.recordlength'
  23805.  
  23806.      The average record length.  This is the exact record length for
  23807.      tables with fixed-length records, because all records have the
  23808.      same length.
  23809.  
  23810.    * `Packed'
  23811.  
  23812.      MySQL strips spaces from the end of strings. The `Packed' value
  23813.      indicates the percentage of savings achieved by doing this.
  23814.  
  23815.    * `Recordspace used'
  23816.  
  23817.      What percentage of the data file is used.
  23818.  
  23819.    * `Empty space'
  23820.  
  23821.      What percentage of the data file is unused.
  23822.  
  23823.    * `Blocks/Record'
  23824.  
  23825.      Average number of blocks per record (that is, how many links a
  23826.      fragmented record is composed of). This is always 1.0 for
  23827.      fixed-format tables. This value should stay as close to 1.0 as
  23828.      possible. If it gets too big, you can reorganize the table.  *Note
  23829.      Optimization::.
  23830.  
  23831.    * `Recordblocks'
  23832.  
  23833.      How many blocks (links) are used. For fixed format, this is the
  23834.      same as the number of records.
  23835.  
  23836.    * `Deleteblocks'
  23837.  
  23838.      How many blocks (links) are deleted.
  23839.  
  23840.    * `Recorddata'
  23841.  
  23842.      How many bytes in the data file are used.
  23843.  
  23844.    * `Deleted data'
  23845.  
  23846.      How many bytes in the data file are deleted (unused).
  23847.  
  23848.    * `Lost space'
  23849.  
  23850.      If a record is updated to a shorter length, some space is lost.
  23851.      This is the sum of all such losses, in bytes.
  23852.  
  23853.    * `Linkdata'
  23854.  
  23855.      When the dynamic table format is used, record fragments are linked
  23856.      with pointers (4 to 7 bytes each). `Linkdata' is the sum of the
  23857.      amount of storage used by all such pointers.
  23858.  
  23859.  
  23860. If a table has been compressed with `myisampack', `myisamchk -d' prints
  23861. additional information about each table column.  See *Note
  23862. `myisampack': myisampack, for an example of this information and a
  23863. description of what it means.
  23864.  
  23865. MySQL Localization and International Usage
  23866. ==========================================
  23867.  
  23868. This section describes how to configure the server to use different
  23869. character sets.  It also discusses how to set the server's time zone
  23870. and enable per-connection time zone support.
  23871.  
  23872. The Character Set Used for Data and Sorting
  23873. -------------------------------------------
  23874.  
  23875. By default, MySQL uses the ISO-8859-1 (Latin1) character set with
  23876. sorting according to Swedish/Finnish rules. These defaults are suitable
  23877. for the United States and most of western Europe.
  23878.  
  23879. All MySQL binary distributions are compiled with
  23880. `--with-extra-charsets=complex'.  This adds code to all standard
  23881. programs that enables them to handle `latin1' and all multi-byte
  23882. character sets within the binary. Other character sets will be loaded
  23883. from a character-set definition file when needed.
  23884.  
  23885. The character set determines what characters are allowed in names. It
  23886. also determines how strings are sorted by the `ORDER BY' and `GROUP BY'
  23887. clauses of the `SELECT' statement.
  23888.  
  23889. You can change the character set with the `--default-character-set'
  23890. option when you start the server.  The character sets available depend
  23891. on the `--with-charset=CHARSET' and `--with-extra-charsets=
  23892. LIST-OF-CHARSETS | complex | all | none' options to `configure', and the
  23893. character set configuration files listed in `SHAREDIR/charsets/Index'.
  23894. *Note `configure' options: configure options.
  23895.  
  23896. As of MySQL 4.1.1, you can also change the character set collation with
  23897. the `--default-collation' option when you start the server.  The
  23898. collation must be a legal collation for the default character set.
  23899. (Use the `SHOW COLLATION' statement to determine which collations are
  23900. available for each character set.)  *Note `configure' options:
  23901. configure options.
  23902.  
  23903. If you change the character set when running MySQL, that may also
  23904. change the sort order.  Consequently, you must run `myisamchk -r -q
  23905. --set-character-set=CHARSET' on all tables, or your indexes may not be
  23906. ordered correctly.
  23907.  
  23908. When a client connects to a MySQL server, the server indicates to the
  23909. client what the server's default character set is.  The client will
  23910. switch to use this character set for this connection.
  23911.  
  23912. You should use `mysql_real_escape_string()' when escaping strings for
  23913. an SQL query.  `mysql_real_escape_string()' is identical to the old
  23914. `mysql_escape_string()' function, except that it takes the `MYSQL'
  23915. connection handle as the first parameter so that the appropriate
  23916. character set can be taken into account when escaping characters.
  23917.  
  23918. If the client is compiled with different paths than where the server is
  23919. installed and the user who configured MySQL didn't include all character
  23920. sets in the MySQL binary, you must tell the client where it can find the
  23921. additional character sets it will need if the server runs with a
  23922. different character set than the client.
  23923.  
  23924. You can do this by specifying a `--character-sets-dir' option to
  23925. indicate the path to the directory in which the dynamic MySQL character
  23926. sets are stored. For example, you can put the following in an option
  23927. file:
  23928.  
  23929.      [client]
  23930.      character-sets-dir=/usr/local/mysql/share/mysql/charsets
  23931.  
  23932. You can force the client to use specific character set as follows:
  23933.  
  23934.      [client]
  23935.      default-character-set=CHARSET
  23936.  
  23937. This is normally unnecessary, however.
  23938.  
  23939. Using the German Character Set
  23940. ..............................
  23941.  
  23942. To get German sorting order, you should start `mysqld' with a
  23943. `--default-character-set=latin1_de' option.  This affects server
  23944. behavior in several ways:
  23945.  
  23946.    * When sorting and comparing strings, the following mapping is
  23947.      performed on the strings before doing the comparison:
  23948.  
  23949.           a"  ->  ae
  23950.           o"  ->  oe
  23951.           u"  ->  ue
  23952.           ss  ->  ss
  23953.  
  23954.    * All accented characters are converted to their unaccented uppercase
  23955.      counterpart.  All letters are converted to uppercase.
  23956.  
  23957.    * When comparing strings with `LIKE', the one-character to
  23958.      two-character mapping is not done. All letters are converted to
  23959.      uppercase. Accents are removed from all letters except `U"', `u"',
  23960.      `O"', `o"', `A"', and `a"'.
  23961.  
  23962.  
  23963. Setting the Error Message Language
  23964. ----------------------------------
  23965.  
  23966. By default, `mysqld' produces error messages in English, but they can
  23967. also be displayed in any of these other languages: Czech, Danish,
  23968. Dutch, Estonian, French, German, Greek, Hungarian, Italian, Japanese,
  23969. Korean, Norwegian, Norwegian-ny, Polish, Portuguese, Romanian, Russian,
  23970. Slovak, Spanish, or Swedish.
  23971.  
  23972. To start `mysqld' with a particular language for error messages, use the
  23973. `--language' or `-L' option. The option value can be a language name or
  23974. the full path to the error message file.  For example:
  23975.  
  23976.      shell> mysqld --language=swedish
  23977.  
  23978. Or:
  23979.  
  23980.      shell> mysqld --language=/usr/local/share/swedish
  23981.  
  23982. The language name should be specified in lowercase.
  23983.  
  23984. The language files are located (by default) in the `share/LANGUAGE'
  23985. directory under the MySQL base directory.
  23986.  
  23987. To change the error message file, you should edit the `errmsg.txt' file,
  23988. and then execute the following command to generate the `errmsg.sys'
  23989. file:
  23990.  
  23991.      shell> comp_err errmsg.txt errmsg.sys
  23992.  
  23993. If you upgrade to a newer version of MySQL, remember to repeat your
  23994. changes with the new `errmsg.txt' file.
  23995.  
  23996. Adding a New Character Set
  23997. --------------------------
  23998.  
  23999. This section discusses the procedure for adding add another character
  24000. set to MySQL.  You must have a MySQL source distribution to use these
  24001. instructions.
  24002.  
  24003. To choose the proper procedure, decide whether the character set is
  24004. simple or complex:
  24005.  
  24006.    * If the character set does not need to use special string collating
  24007.      routines for sorting and does not need multi-byte character
  24008.      support, it is simple.
  24009.  
  24010.    * If it needs either of those features, it is complex.
  24011.  
  24012.  
  24013. For example, `latin1' and `danish' are simple character sets, whereas
  24014. `big5' and `czech' are complex character sets.
  24015.  
  24016. In the following procedures, the name of your character set is
  24017. represented by MYSET.
  24018.  
  24019. For a simple character set, do the following:
  24020.  
  24021.   1. Add MYSET to the end of the `sql/share/charsets/Index' file.
  24022.      Assign a unique number to it.
  24023.  
  24024.   2. Create the file `sql/share/charsets/MYSET.conf'.  (You can use a
  24025.      copy of `sql/share/charsets/latin1.conf' as the basis for this
  24026.      file.)
  24027.  
  24028.      The syntax for the file is very simple:
  24029.  
  24030.         * Comments start with a `#' character and proceed to the end of
  24031.           the line.
  24032.  
  24033.         * Words are separated by arbitrary amounts of whitespace.
  24034.  
  24035.         * When defining the character set, every word must be a number
  24036.           in hexadecimal format.
  24037.  
  24038.         * The `ctype' array takes up the first 257 words. The
  24039.           `to_lower[]', `to_upper[]' and `sort_order[]' arrays take up
  24040.           256 words each after that.
  24041.  
  24042.      *Note Character arrays::.
  24043.  
  24044.   3. Add the character set name to the `CHARSETS_AVAILABLE' and
  24045.      `COMPILED_CHARSETS' lists in `configure.in'.
  24046.  
  24047.   4. Reconfigure, recompile, and test.
  24048.  
  24049.  
  24050. For a complex character set, do the following:
  24051.  
  24052.   1. Create the file `strings/ctype-MYSET.c' in the MySQL source
  24053.      distribution.
  24054.  
  24055.   2. Add MYSET to the end of the `sql/share/charsets/Index' file.
  24056.      Assign a unique number to it.
  24057.  
  24058.   3. Look at one of the existing `ctype-*.c' files (such as
  24059.      `strings/ctype-big5.c') to see what needs to be defined.  Note
  24060.      that the arrays in your file must have names like `ctype_MYSET',
  24061.      `to_lower_MYSET', and so on.  These correspond to the arrays for a
  24062.      simple character set. *Note Character arrays::.
  24063.  
  24064.   4. Near the top of the file, place a special comment like this:
  24065.  
  24066.           /*
  24067.            * This comment is parsed by configure to create ctype.c,
  24068.            * so don't change it unless you know what you are doing.
  24069.            *
  24070.            * .configure. number_MYSET=MYNUMBER
  24071.            * .configure. strxfrm_multiply_MYSET=N
  24072.            * .configure. mbmaxlen_MYSET=N
  24073.            */
  24074.  
  24075.      The `configure' program uses this comment to include the character
  24076.      set into the MySQL library automatically.
  24077.  
  24078.      The `strxfrm_multiply' and `mbmaxlen' lines are explained in the
  24079.      following sections.  You need include them only if you need the
  24080.      string collating functions or the multi-byte character set
  24081.      functions, respectively.
  24082.  
  24083.   5. You should then create some of the following functions:
  24084.  
  24085.         * `my_strncoll_MYSET()'
  24086.  
  24087.         * `my_strcoll_MYSET()'
  24088.  
  24089.         * `my_strxfrm_MYSET()'
  24090.  
  24091.         * `my_like_range_MYSET()'
  24092.  
  24093.      *Note String collating::.
  24094.  
  24095.   6. Add the character set name to the `CHARSETS_AVAILABLE' and
  24096.      `COMPILED_CHARSETS' lists in `configure.in'.
  24097.  
  24098.   7. Reconfigure, recompile, and test.
  24099.  
  24100. The `sql/share/charsets/README' file includes additional instructions.
  24101.  
  24102. If you want to have the character set included in the MySQL
  24103. distribution, mail a patch to the MySQL `internals' mailing list.
  24104. *Note Mailing-list::.
  24105.  
  24106. The Character Definition Arrays
  24107. -------------------------------
  24108.  
  24109. `to_lower[]' and `to_upper[]' are simple arrays that hold the lowercase
  24110. and uppercase characters corresponding to each member of the character
  24111. set.  For example:
  24112.  
  24113.      to_lower['A'] should contain 'a'
  24114.      to_upper['a'] should contain 'A'
  24115.  
  24116. `sort_order[]' is a map indicating how characters should be ordered for
  24117. comparison and sorting purposes. Quite often (but not for all character
  24118. sets) this is the same as `to_upper[]', which means that sorting will be
  24119. case-insensitive. MySQL will sort characters based on the values of
  24120. `sort_order[]' elements.  For more complicated sorting rules, see the
  24121. discussion of string collating in *Note String collating::.
  24122.  
  24123. `ctype[]' is an array of bit values, with one element for one character.
  24124. (Note that `to_lower[]', `to_upper[]', and `sort_order[]' are indexed
  24125. by character value, but `ctype[]' is indexed by character value + 1.
  24126. This is an old legacy convention to be able to handle `EOF'.)
  24127.  
  24128. You can find the following bitmask definitions in `m_ctype.h':
  24129.  
  24130.      #define _U      01      /* Uppercase */
  24131.      #define _L      02      /* Lowercase */
  24132.      #define _N      04      /* Numeral (digit) */
  24133.      #define _S      010     /* Spacing character */
  24134.      #define _P      020     /* Punctuation */
  24135.      #define _C      040     /* Control character */
  24136.      #define _B      0100    /* Blank */
  24137.      #define _X      0200    /* heXadecimal digit */
  24138.  
  24139. The `ctype[]' entry for each character should be the union of the
  24140. applicable bitmask values that describe the character.  For example,
  24141. `'A'' is an uppercase character (`_U') as well as a hexadecimal digit
  24142. (`_X'), so `ctype['A'+1]' should contain the value:
  24143.  
  24144.      _U + _X = 01 + 0200 = 0201
  24145.  
  24146. String Collating Support
  24147. ------------------------
  24148.  
  24149. If the sorting rules for your language are too complex to be handled
  24150. with the simple `sort_order[]' table, you need to use the string
  24151. collating functions.
  24152.  
  24153. Right now the best documentation for this is the character sets that are
  24154. already implemented.  Look at the `big5', `czech', `gbk', `sjis', and
  24155. `tis160' character sets for examples.
  24156.  
  24157. You must specify the `strxfrm_multiply_MYSET=N' value in the special
  24158. comment at the top of the file.  N should be set to the maximum ratio
  24159. the strings may grow during `my_strxfrm_MYSET' (it must be a positive
  24160. integer).
  24161.  
  24162. Multi-Byte Character Support
  24163. ----------------------------
  24164.  
  24165. If you want to add support for a new character set that includes
  24166. multi-byte characters, you need to use the multi-byte character
  24167. functions.
  24168.  
  24169. Right now the best documentation on this consists of the character sets
  24170. that are already implemented.  Look at the `euc_kr', `gb2312', `gbk',
  24171. `sjis', and `ujis' character sets for examples. These are implemented
  24172. in the `ctype-CHARSET.c' files in the `strings' directory.
  24173.  
  24174. You must specify the `mbmaxlen_MYSET=N' value in the special comment at
  24175. the top of the source file.  N should be set to the size in bytes of
  24176. the largest character in the set.
  24177.  
  24178. Problems With Character Sets
  24179. ----------------------------
  24180.  
  24181. If you try to use a character set that is not compiled into your binary,
  24182. you might run into the following problems:
  24183.  
  24184.    * Your program has an incorrect path to where the character sets are
  24185.      stored.  (Default `/usr/local/mysql/share/mysql/charsets').  This
  24186.      can be fixed by using the `--character-sets-dir' option when you
  24187.      run the program in question.
  24188.  
  24189.    * The character set is a multi-byte character set that can't be
  24190.      loaded dynamically.  In this case, you must recompile the program
  24191.      with support for the character set.
  24192.  
  24193.    * The character set is a dynamic character set, but you don't have a
  24194.      configure file for it.  In this case, you should install the
  24195.      configure file for the character set from a new MySQL distribution.
  24196.  
  24197.    * If your `Index' file doesn't contain the name for the character
  24198.      set, your program will display the following error message:
  24199.  
  24200.           ERROR 1105: File '/usr/local/share/mysql/charsets/?.conf'
  24201.           not found (Errcode: 2)
  24202.  
  24203.      In this case, you should either get a new `Index' file or manually
  24204.      add the name of any missing character sets to the current file.
  24205.  
  24206. For `MyISAM' tables, you can check the character set name and number
  24207. for a table with `myisamchk -dvv TBL_NAME'.
  24208.  
  24209. MySQL Server Time Zone Support
  24210. ------------------------------
  24211.  
  24212. Before MySQL 4.1.3, you can set the time zone for the server with the
  24213. `--timezone=timezone_name' option to `mysqld_safe'.  You can also set
  24214. it by setting the `TZ' environment variable before you start `mysqld'.
  24215.  
  24216. The allowable values for `--timezone' or `TZ' are system-dependent.
  24217. Consult your operating system documentation to see what values are
  24218. acceptable.
  24219.  
  24220. Beginning with MySQL 4.1.3, the server maintains several time zone
  24221. settings:
  24222.  
  24223.    * The system time zone.  When the server starts, it attempts to
  24224.      determine the time zone of the host machine and uses it to set the
  24225.      `system_time_zone' system variable.
  24226.  
  24227.    * The server's current time zone. The global `time_zone' system
  24228.      variable indicates the time zone the server currently is operating
  24229.      in. The initial value is `'SYSTEM'', which indicates that the
  24230.      server time zone is the same as the system time zone. The initial
  24231.      value can be specified explicitly with the
  24232.      `--default-time-zone=TIMEZONE' option.  If you have the `SUPER'
  24233.      privilege, you can set the global value at runtime with this
  24234.      statement:
  24235.  
  24236.           mysql> SET GLOBAL time_zone = TIMEZONE;
  24237.  
  24238.    * Per-connection time zones. Each client that connects has its own
  24239.      time zone setting, given by the session `time_zone' variable.
  24240.      Initially this is the same as the global `time_zone' variable, but
  24241.      can be reset with this statement:
  24242.  
  24243.           mysql> SET time_zone = TIMEZONE;
  24244.  
  24245.  
  24246. The current values of the global and per-connection time zones can be
  24247. retrieved like this:
  24248.  
  24249.      mysql> SELECT @global.time_zone, @session.time_zone;
  24250.  
  24251. TIMEZONE values can be given as strings indicating an offset from UTC,
  24252. such as `'+10:00'' or `'-6:00''. If the time zone-related tables in the
  24253. `mysql' database have been created and populated, you can also used
  24254. named time zones, such as `'Europe/Helsinki'', `'US/Eastern'', or
  24255. `'MET''. The value `'SYSTEM'' indicates that the time zone should be
  24256. the same as the system time zone.  Time zone names are not case
  24257. sensitive.
  24258.  
  24259. The MySQL installation procedure creates the time zone tables in the
  24260. `mysql' database, but does not load them. You must do so manually.  (If
  24261. you are upgrading to MySQL 4.1.3 or later from an earlier version, you
  24262. should create the tables by upgrading your `mysql' database. Use the
  24263. instructions in *Note Upgrading-grant-tables::.)
  24264.  
  24265. *Note*: Currently, time time zone tables can be populated only on Unix.
  24266. This problem will be addressed soon for Windows.
  24267.  
  24268. The `mysql_tzinfo_to_sql' program is used to load the time zone tables.
  24269. You will need to know the directory under which your system's time zone
  24270. files are stored.  A likely location is `/usr/share/zoneinfo'.  Pass
  24271. the directory name on the command line to `mysql_tzinfo_to_sql', and
  24272. send the output into the `mysql' program. For example:
  24273.  
  24274.      shell> mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql
  24275.  
  24276. `mysql_tzinfo_to_sql' reads your system's time zone files and generates
  24277. SQL statements from them.  `mysql' processes those statements to load
  24278. the time zone tables.
  24279.  
  24280. `mysql_tzinfo_to_sql' also can be used to load a single time zone file,
  24281. and to generate leap second information.
  24282.  
  24283. To load a single time zone file TZ_FILE that corresponds to a time zone
  24284. name TZ_NAME, invoke `mysql_tzinfo_to_sql' like this:
  24285.  
  24286.      shell> mysql_tzinfo_to_sql TZ_FILE TZ_NAME | mysql -u root mysql
  24287.  
  24288. If your time zone needs to account for leap seconds, initialize the
  24289. leap second information like this, where TZ_FILE is the name of your
  24290. time zone file:
  24291.  
  24292.      shell> mysql_tzinfo_to_sql --leap TZ_FILE | mysql -u root mysql
  24293.  
  24294. The MySQL Log Files
  24295. ===================
  24296.  
  24297. MySQL has several different log files that can help you find out what's
  24298. going on inside `mysqld':
  24299.  
  24300. *Log File*     *Types of Information Logged to File*
  24301. The error log  Logs problems encountered starting, running, or stopping
  24302.                `mysqld'.
  24303. The isam log   Logs all changes to the `ISAM' tables. Used only for
  24304.                debugging the isam code.
  24305. The query log  Logs established client connections and executed
  24306.                statements.
  24307. The update     Logs statements that change data. This log is deprecated.
  24308. log            
  24309. The binary     Logs all statements that change data. Also used for
  24310. log            replication.
  24311. The slow log   Logs all queries that took more than `long_query_time'
  24312.                seconds to execute or didn't use indexes.
  24313.  
  24314. By default, all logs are created in the `mysqld' data directory.  You
  24315. can force `mysqld' to close and reopen the log files (or in some cases
  24316. switch to a new log) by flushing the logs. Log flushing occurs when you
  24317. issue a `FLUSH LOGS' statement or execute `mysqladmin flush-logs' or
  24318. `mysqladmin refresh'.  *Note FLUSH::.
  24319.  
  24320. If you are using MySQL replication capabilities, slave replication
  24321. servers maintain additional log files called relay logs. These are
  24322. discussed in *Note Replication::.
  24323.  
  24324. The Error Log
  24325. -------------
  24326.  
  24327. The error log file contains information indicating when `mysqld' was
  24328. started and stopped and also any critical errors that occur while the
  24329. server is running.
  24330.  
  24331. If `mysqld' dies unexpectedly and `mysqld_safe' needs to restart it,
  24332. `mysqld_safe' will write a `restarted mysqld' message to the error log.
  24333. If `mysqld' notices a table that needs to be automatically checked or
  24334. repaired, it writes a message to the error log.
  24335.  
  24336. On some operating systems, the error log will contain a stack trace if
  24337. `mysqld' dies. The trace can be used to determine where `mysqld' died.
  24338. *Note Using stack trace::.
  24339.  
  24340. Beginning with MySQL 4.0.10, you can specify where `mysqld' stores the
  24341. error log file with the `--log-error[=FILE_NAME]' option. If no
  24342. FILE_NAME value is given, `mysqld' uses the name `HOST_NAME.err' and
  24343. writes the file in the data directory.  (Prior to MySQL 4.0.10, the
  24344. Windows error log name is `mysql.err'.)  If you execute `FLUSH LOGS',
  24345. the error log is renamed with a suffix of `-old' and `mysqld' creates a
  24346. new empty log file.
  24347.  
  24348. In older MySQL versions on Unix, error log handling was done by
  24349. `mysqld_safe' which redirected the error file to `HOST_NAME.err'.  You
  24350. could change this filename by specifying a `--err-log=FILE_NAME' option
  24351. to `mysqld_safe'.
  24352.  
  24353. If you don't specify `--log-error', or (on Windows) if you use the
  24354. `--console' option, errors are written to stderr, the standard error
  24355. output. Usually this is your terminal.
  24356.  
  24357. On Windows, error output is always written to the `.err' file if
  24358. `--console' is not given.
  24359.  
  24360. The General Query Log
  24361. ---------------------
  24362.  
  24363. If you want to know what happens within `mysqld', you should start it
  24364. with the `--log[=FILE_NAME]' or `-l [FILE_NAME]' option.  If no
  24365. FILE_NAME value is given, the default name is `HOST_NAME.log' This will
  24366. log all connections and statements to the log file.  This log can be
  24367. very useful when you suspect an error in a client and want to know
  24368. exactly what the client sent to `mysqld'.
  24369.  
  24370. Older versions of the `mysql.server' script (from MySQL 3.23.4 to
  24371. 3.23.8) pass a `--log' option to `safe_mysqld' to enable the general
  24372. query log.  If you need better performance when you start using MySQL
  24373. in a production environment, you can remove the `--log' option from
  24374. `mysql.server' or change it to `--log-bin'. *Note Binary log::.
  24375.  
  24376. `mysqld' writes statements to the query log in the order that it
  24377. receives them.  This may be different from the order in which they are
  24378. executed.  This is in contrast to the update log and the binary log,
  24379. which are written after the query is executed, but before any locks are
  24380. released.
  24381.  
  24382. Server restarts and log flushing do not cause a new general query log
  24383. file to be generated (although flushing closes and reopens it). On
  24384. Unix, you can rename the file and create a new one by using the
  24385. following commands:
  24386.  
  24387.      shell> mv hostname.log hostname-old.log
  24388.      shell> mysqladmin flush-logs
  24389.      shell> cp hostname-old.log to-backup-directory
  24390.      shell> rm hostname-old.log
  24391.  
  24392. On Windows, you cannot rename the log file while the server has it open.
  24393. You must stop the server and rename the log. Then restart the server to
  24394. create a new log.
  24395.  
  24396. The Update Log
  24397. --------------
  24398.  
  24399. *Note*: The update log has been deprecated and replaced by the binary
  24400. log. *Note Binary log::.  The binary log can do anything the old update
  24401. log could do, and more. _The update log is unavailable as of MySQL
  24402. 5.0.0_.
  24403.  
  24404. When started with the `--log-update[=FILE_NAME]' option, `mysqld'
  24405. writes a log file containing all SQL statements that update data. If no
  24406. FILE_NAME value is given, the default name is name of the host machine.
  24407. If a filename is given, but it doesn't contain a leading path, the file
  24408. is written in the data directory. If `file_name' doesn't have an
  24409. extension, `mysqld' creates log files with names of the form
  24410. FILE_NAME.###, where ### is a number that is incremented each time you
  24411. start the server or flush the logs.
  24412.  
  24413. *Note*: For this naming scheme to work, you must not create your own
  24414. files with the same names as those that might be used for the log file
  24415. sequence.
  24416.  
  24417. Update logging is smart because it logs only statements that really
  24418. update data. So, an `UPDATE' or a `DELETE' with a `WHERE' that finds no
  24419. rows is not written to the log. It even skips `UPDATE' statements that
  24420. set a column to the value it already has.
  24421.  
  24422. The update logging is done immediately after a query completes but
  24423. before any locks are released or any commit is done. This ensures that
  24424. statements are logged in execution order.
  24425.  
  24426. If you want to update a database from update log files, you could do the
  24427. following (assuming that your update logs have names of the form
  24428. `file_name.###'):
  24429.  
  24430.      shell> ls -1 -t -r file_name.[0-9]* | xargs cat | mysql
  24431.  
  24432. `ls' is used to sort the update log filenames into the right order.
  24433.  
  24434. This can be useful if you have to revert to backup files after a crash
  24435. and you want to redo the updates that occurred between the time of the
  24436. backup and the crash.
  24437.  
  24438. The Binary Log
  24439. --------------
  24440.  
  24441. The binary log has replaced the old update log, which is unavailable
  24442. starting from MySQL 5.0. The binary log contains all information that is
  24443. available in the update log in a more efficient format and in a manner
  24444. that is transactionally safe.
  24445.  
  24446. The binary log contains all statements which updated data or (starting
  24447. from MySQL 4.1.3) could potentially have updated it (for example, a
  24448. `DELETE' which matched no rows).
  24449.  
  24450. The binary log also contains information about how long each statement
  24451. took that updated the database.  It doesn't contain statements that
  24452. don't modify any data.  If you want to log all statements (for example,
  24453. to identify a problem query) you should use the general query log.
  24454. *Note Query log::.
  24455.  
  24456. The primary purpose of the binary log is to be able to update the
  24457. database during a restore operation as fully as possible, because the
  24458. binary log will contain all updates done after a backup was made.
  24459.  
  24460. The binary log is also used on master replication servers as a record
  24461. of the statements to be sent to slave servers.  *Note Replication::.
  24462.  
  24463. Running the server with the binary log enabled makes performance about
  24464. 1% slower. However, the benefits of the binary log for restore
  24465. operations and in allowing you to set up replication generally outweigh
  24466. this minor performance decrement.
  24467.  
  24468. When started with the `--log-bin[=FILE_NAME]' option, `mysqld' writes a
  24469. log file containing all SQL commands that update data. If no FILE_NAME
  24470. value is given, the default name is the name of the host machine
  24471. followed by `-bin'. If file name is given, but it doesn't contain a
  24472. path, the file is written in the data directory.
  24473.  
  24474. If you supply an extension in the log name (for example,
  24475. `--log-bin=FILE_NAME.EXTENSION'), the extension is silently removed and
  24476. ignored.
  24477.  
  24478. `mysqld' appends a numeric extension to the binary log name. The number
  24479. is incremented each time you start the server or flush the logs.  A new
  24480. binary log also is created automatically when the current log's size
  24481. reaches `max_binlog_size'. A binary log may become larger than
  24482. `max_binlog_size' if you are using large transactions: A transaction is
  24483. written to the binary log in one piece, never split between binary logs.
  24484.  
  24485. To be able to know which different binary log files have been used,
  24486. `mysqld' also creates a binary log index file that contains the name of
  24487. all used binary log files. By default this has the same name as the
  24488. binary log file, with the extension `'.index''.  You can change the
  24489. name of the binary log index file with the
  24490. `--log-bin-index[=FILE_NAME]' option.  You should not manually edit
  24491. this file while `mysqld' is running; doing so would confuse `mysqld'.
  24492.  
  24493. You can delete all binary log files with the `RESET MASTER' statement,
  24494. or only some of them with `PURGE MASTER LOGS'.  See *Note `RESET':
  24495. RESET and *Note Replication Master SQL::.
  24496.  
  24497. You can use the following options to `mysqld' to affect what is logged
  24498. to the binary log. See also the discussion that follows this option
  24499. list.
  24500.  
  24501. `--binlog-do-db=DB_NAME'
  24502.      Tells the master that it should log updates to the binary log if
  24503.      the current database (that is, the one selected by `USE') is
  24504.      DB_NAME. All other databases that are not explicitly mentioned are
  24505.      ignored.  If you use this, you should ensure that you only do
  24506.      updates in the current database.
  24507.  
  24508.      An example of what does not work as you might expect: If the
  24509.      server is started with `binlog-do-db=sales', and you do `USE
  24510.      prices; UPDATE sales.january SET amount=amount+1000;', this
  24511.      statement will not be written into the binary log.
  24512.  
  24513. `--binlog-ignore-db=DB_NAME'
  24514.      Tells the master that updates where the current database (that is,
  24515.      the one selected by `USE') is DB_NAME should not be stored in the
  24516.      binary log.  If you use this, you should ensure that you only do
  24517.      updates in the current database.
  24518.  
  24519.      An example of what does not work as you might expect: If the
  24520.      server is started with `binlog-ignore-db=sales', and you do `USE
  24521.      prices; UPDATE sales.january SET amount=amount+1000;', this
  24522.      statement will be written into the binary log.
  24523.  
  24524. To log or ignore multiple databases, specify the appropriate option
  24525. multiple times, once for each database.
  24526.  
  24527. The rules for logging or ignoring updates to the binary log are
  24528. evaluated in the following order:
  24529.  
  24530.   1. Are there `binlog-do-db' or `binlog-ignore-db' rules?
  24531.         * No: Write the statement to the binary log and exit.
  24532.  
  24533.         * Yes: Go to the next step.
  24534.  
  24535.   2. There are some rules (`binlog-do-db' or `binlog-ignore-db' or
  24536.      both). Is there a current database (has any database been selected
  24537.      by `USE'?)?
  24538.         * No: Do _not_ write the statement, and exit.
  24539.  
  24540.         * Yes: Go to the next step.
  24541.  
  24542.   3. There is a current database. Are there some `binlog-do-db' rules?
  24543.         * Yes: Does the current database match any of the `binlog-do-db'
  24544.           rules?
  24545.              * Yes: Write the statement and exit.
  24546.  
  24547.              * No: Do _not_ write the statement, and exit.
  24548.  
  24549.         * No: Go to the next step.
  24550.  
  24551.   4. There are some `binlog-ignore-db' rules.  Does the current
  24552.      database match any of the `binlog-ignore-db' rules?
  24553.         * Yes: Do not write the statement, and exit.
  24554.  
  24555.         * No: Write the query and exit.
  24556.  
  24557. For example, a slave running with only `binlog-do-db=sales' will not
  24558. write to the binary log any statement whose current database is
  24559. different from `sales' (in other words, `binlog-do-db' can sometimes
  24560. mean "ignore other databases").
  24561.  
  24562. If you are using replication, you should not delete old binary log
  24563. files until you are sure that no slave still needs to use them.  One
  24564. way to do this is to do `mysqladmin flush-logs' once a day and then
  24565. remove any logs that are more than three days old. You can remove them
  24566. manually, or preferably using `PURGE MASTER LOGS' (*note Replication
  24567. Master SQL::), which will also safely update the binary log index file
  24568. for you  (and which can take a date argument since MySQL 4.1)
  24569.  
  24570. A client with the `SUPER' privilege can disable binary logging of its
  24571. own statements by using a `SET SQL_LOG_BIN=0' statement. *Note `SET':
  24572. SET OPTION.
  24573.  
  24574. You can examine the binary log file with the `mysqlbinlog' utility.
  24575. This can be useful when you want to reprocess statements in the log.
  24576. For example, you can update a MySQL server from the binary log as
  24577. follows:
  24578.  
  24579.      shell> mysqlbinlog log-file | mysql -h server_name
  24580.  
  24581. See *Note `mysqlbinlog': mysqlbinlog for more information on the
  24582. `mysqlbinlog' utility and how to use it.
  24583.  
  24584. If you are using transactions, you must use the MySQL binary log for
  24585. backups instead of the old update log.
  24586.  
  24587. The binary logging is done immediately after a query completes but
  24588. before any locks are released or any commit is done. This ensures that
  24589. the log will be logged in the execution order.
  24590.  
  24591. Updates to non-transactional tables are stored in the binary log
  24592. immediately after execution.  For transactional tables such as `BDB' or
  24593. `InnoDB' tables, all updates (`UPDATE', `DELETE', or `INSERT') that
  24594. change tables are cached until a `COMMIT' statement is received by the
  24595. server. At that point, `mysqld' writes the whole transaction to the
  24596. binary log before the `COMMIT' is executed.  When the thread that
  24597. handles the transaction starts, it allocates a buffer of
  24598. `binlog_cache_size' to buffer queries.  If a statement is bigger than
  24599. this, the thread opens a temporary file to store the transaction.  The
  24600. temporary file is deleted when the thread ends.
  24601.  
  24602. The `max_binlog_cache_size' (default 4GB) can be used to restrict the
  24603. total size used to cache a multiple-statement transaction.  If a
  24604. transaction is larger than this, it will fail and roll back.
  24605.  
  24606. If you are using the update log or binary log, concurrent inserts will
  24607. be converted to normal inserts when using `CREATE ... SELECT' or
  24608. `INSERT ... SELECT'.  This is to ensure that you can re-create an exact
  24609. copy of your tables by applying the log on a backup.
  24610.  
  24611. The binary log format is different in versions 3.23, 4.0, and 5.0.0.
  24612. Those format changes were required to implement enhancements to
  24613. replication.  MySQL 4.1 has the same binary log format as 4.0.  *Note
  24614. Replication Compatibility::.
  24615.  
  24616. By default, the binary log is not synchronized to disk at each write. So
  24617. if the operating system or machine (not only the MySQL server) crashes
  24618. there is a chance that the last statements of the binary log are lost.
  24619. To prevent this, you can make the binary log be synchronized to disk
  24620. after every Nth binary log write, with the `sync_binlog' global variable
  24621. (1 being the safest value, but also the slowest). *Note Server system
  24622. variables::.  Even with this set to 1, there is still the chance of an
  24623. inconsistency between the tables content and the binary log content in
  24624. case of crash. For example, if using `InnoDB' tables, and the MySQL
  24625. server processes a `COMMIT' statement, it writes the whole transaction
  24626. to the binary log and then commits this transaction into `InnoDB'. If
  24627. it crashes between those two operations, at restart the transaction
  24628. will be rolled back by InnoDB but still exist in the binary log. This
  24629. problem can be solved with the `--innodb-safe-binlog' option (available
  24630. starting from MySQL 4.1.3), which adds consistency between the content
  24631. of `InnoDB' tables and the binary log. For this option to really bring
  24632. safety to you, the MySQL server should also be configured to
  24633. synchronize to disk, at every transaction, the binary log
  24634. (`sync_binlog=1') and (which is true by default) the `InnoDB' logs.
  24635. The effect of this option is that at restart after a crash, after doing
  24636. a rollback of transactions, the MySQL server will cut rolled back
  24637. `InnoDB' transactions from the binary log. This ensures that the binary
  24638. log reflects the exact data of `InnoDB' tables, and so, that the slave
  24639. remains in sync with the master (not receiving a statement which has
  24640. been rolled back).  Note that `--innodb-safe-binlog' can be used even
  24641. if the MySQL server updates other storage engines than InnoDB. Only
  24642. statements/transactions affecting `InnoDB' tables are subject to being
  24643. removed from the binary log at `InnoDB''s crash recovery.  If at crash
  24644. recovery the MySQL server discovers that the binary log is shorter than
  24645. it should have been (that is, it lacks at least one successfully
  24646. committed `InnoDB' transaction), which should not happen if
  24647. `sync_binlog=1' and the disk/filesystem do an actual sync when they are
  24648. requested to (some don't), it will print an error message ("The binary
  24649. log <name> is shorter than its expected size"). In this case, this
  24650. binary log is not correct, replication should be restarted from a fresh
  24651. master's data snapshot.
  24652.  
  24653. The binary log format has some limitations which apply when the client
  24654. sessions change their character set and collation variables. *Note
  24655. Replication Features::.
  24656.  
  24657. The Slow Query Log
  24658. ------------------
  24659.  
  24660. When started with the `--log-slow-queries[=FILE_NAME]' option, `mysqld'
  24661. writes a log file containing all SQL statements that took more than
  24662. `long_query_time' seconds to execute. The time to acquire the initial
  24663. table locks are not counted as execution time.
  24664.  
  24665. If no FILE_NAME value is given, the default is the name of the host
  24666. machine with a suffix of `-slow.log'. If a filename is given, but
  24667. doesn't contain a path, the file is written in the data directory.
  24668.  
  24669. A statement is logged to the slow query log after it has been executed
  24670. and after all locks have been released. Log order may be different from
  24671. execution order.
  24672.  
  24673. The slow query log can be used to find queries that take a long time to
  24674. execute and are therefore candidates fo