2011-02-15 wcdj
MySQL —— The world's most popular open source database
(1) Get Started with MySQL
One of the reasons MySQL is so popular is that it runs on so many platforms. Whether you run Windows, Mac OSX, Linux, OpenSolaris, or some other platform, there is likely a matching version of MySQL. Because each of these popular platforms is unique, so are the installation procedures for them.
(2) How to Get MySQL
Check downloads page at http://dev.mysql.com/downloads/ for information about the current version of MySQL and for downloading instructions.
(3) Installing MySQL on Windows
安装说明 :http://dev.mysql.com/doc/refman/5.0/en/windows-installation.html
mysql-installation-excerpt-5.5-en.pdf : http://downloads.mysql.com/docs/mysql-installation-excerpt-5.5-en.pdf
mysql-tutorial-excerpt-5.5-en.pdf :http://downloads.mysql.com/docs/mysql-tutorial-excerpt-5.5-en.pdf
Planning
[1] The typical install of MySQL 5.0 on Windows takes about 90MB plus space for data
Approximately 60MB for the software
Approximately 30MB for the database skeleton
[2] The software is installed to C:/Program Files/MySQL by default
[3] The data files are installed at C:/Program Files/MySQL/MySQL Server 5.0/data by default. This can be changed using the Server Configuration Wizard .
[4] The amount of space required to store a given amount of data depends on the table type used and other factors. InnoDB uses the most storage while archive uses the least.
Installation and Initial Configuration
The installation process uses a standard Windows installation wizard. Nearly all of the screens are entirely self-explanatory, and no configuration information for the software is entered at this statge.
When the software installation completes, a configuration wizard will run which contains the options which require more discussion. Should you decide not to run the wizard at that time, or should you decide to change your configuration later, the configuration wizard is also installed along with the software and can be located in the start menu.
安装时遇到的选项:
1) Please select a configuration type.
In general, this tutorial focuses on the default option ("Choose this configuration type to create the optimal sever setup for this machine.")
2) Please select the database usage.
In most cases, you may want to consider this choice somewhat carefully. The main table types supported on Windows are MyISAM and InnoDB. These use fundamentally different techniques for maintaining concurrent data and have different strengths and weaknesses.
MyISAM
MyISAM was the first major table type that MySQL supported. It has no transactional rollback capability, and concurrency is controlled using table locks. It is optimized for rapid searches, but trades substantial data integrity controls for this performance gain. Foreign key constraints are not supported on MyISAM tables. For basic content management systems, it is probably the preferred table type.
InnoDB
InnoDB (licensed now from Oracle), provides a Multi-Version Concurrency Control based storage engine similar in some ways to PostgreSQL. InnoDB is far slower than MyISAM for simple data retrieval, but would be expected to perform better when large numbers of inserts, updates, and selects must happen concurrently. This is because locking is not generally necessary to manage concurrency. However, full text indexing is not supported on this table type.
Other table types exist (Heap, Merge, BDB being a few) but will be covered separately, as they are not generally as widely used as MyISAM and InnoDB.
3) Please select the drive for the InnoDB datafile.
If InnoDB is available, you will then be asked where you want that engine to store its files. The default is the data directory in the installation directory. Developer systems can leave this at the default. Production servers may do better to move this to a RAID array or similar device.
4) Please set the networking options.
Strict mode is an important new feature in MySQL 5.0. In prior versions, MySQL tried very hard to commit a transaction without aborting it. Numbers would be truncated silently, and dates like Feb 31, 2007 would be accepted as valid. Because this sort of behavior was causing MySQL to be dismissed from projects requiring a "serious RDBMS" strict mode was added. This feature tightens down the validity checks on entered data but may break older applications.
Note that strict mode can be turned off by users or applications on a per-connection basis so one should not use it as a major protection for data integrity. It is, however, one more protection which may be useful.
(4) A Note on Table Types
MySQL uses an abstraction layer to allow different methods to be used to store data within the same database. Each table type has its own benefits and drawbacks, and using the wrong table type can cause some data integrity controls to silently fail.
The main table types available in MySQL on Windows are (in alphabetical order):
[1] ARCHIVE
This storage engine uses a compressed flat file to store large amount of information. Indexes are not supported, nor are transactions.
[2] BDB
This storage engine uses the Berkeley Database Engine, developed by Sleepycat Software (recently acquired by Oracle) as a back-end. It does not perform as well as InnoDB under load, but appears to take up less disk space. It may be worth considering when concurrency is expected to be low but space is at a premium.
[3] FEDERATED
This storage engine allows for management of external data on other MySQL servers. No data is stored in a FEDERATED table itself. There is no transaction support.
[4] InnoDB
This table uses a row-versioning in order to allow for transactional consistency. The back-end for this table was originally developed by Innobase (acquired recently by Oracle). It is licensed under the GPL, and MySQL AB purchases additional licenses for their enterprise customers. It requires more space.
[5] MERGE
This storage engine allows for partitioning of data across MyISAM tables. The MERGE is just the parent table (where no data is actually stored), while identical tables hold the partitions.
[6] MEMORY
This storage engine forces an entire table to be stored entirely in memory and never written to disk. It is therefore not ACID compliant, but is sometimes used as a useful developer tool ( sort of an SQL interface to shared memory segments).
[7] MyISAM
This table type uses a flat file to store the data, and auxiliary files for indexes and metadata. Because there are no provisions for keeping data around after it is updated, MyISAM does not support transactional operations. It is the oldest table type still supported.
To create a table with a specific table type, you can use the optional ENGINE keyword. For example:
create table foo ( bar INT ) ENGINE = InnoDB;
Note that currently only the InnoDB and BDB engines are transaction-safe. Furthermore, if an engine is not recognized by the create table statement or is not usable, the system will automatically fall back to MyISAM tables and thus support for foreign constraints and transaction rollback can be silently lost if one is careless.
参考:
[1] http://dev.mysql.com/
[2] MySQL 5.1参考手册 http://dev.mysql.com/doc/refman/5.1/zh/index.html