e-book - mySQL Manual.pdf

(3165 KB) Pobierz
548608013 UNPDF
MySQL Reference Manual
Copyright c 1997-2001 MySQL AB
i
Table of Contents
1 General Information About MySQL. . . . . . . . . 1
1.1 About This Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1.1 Conventions Used in This Manual . . . . . . . . . . . . . . . . 2
1.2 What Is MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2.1 History of MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2.2 The Main Features of MySQL . . . . . . . . . . . . . . . . . . . 5
1.2.3 How Stable Is MySQL? . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2.4 How Big Can MySQL Tables Be? . . . . . . . . . . . . . . . . 8
1.2.5 Year 2000 Compliance . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.3 What Is MySQL AB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.3.1 The Business Model and Services of MySQL AB . . 12
1.3.1.1 Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.3.1.2 Training and Certication . . . . . . . . . . . . . 12
1.3.1.3 Consulting . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.3.1.4 Commercial Licenses . . . . . . . . . . . . . . . . . . 13
1.3.1.5 Partnering . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.3.1.6 Advertising . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.3.2 Contact Information . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.4 MySQL Support and Licensing . . . . . . . . . . . . . . . . . . . . . . . . . . 15
1.4.1 Support Oered by MySQL AB . . . . . . . . . . . . . . . . . 15
1.4.2 Copyrights and Licenses Used by MySQL . . . . . . . . 16
1.4.3 MySQL Server Licenses . . . . . . . . . . . . . . . . . . . . . . . . 17
1.4.3.1 Using the MySQL Server Under a
Commercial License . . . . . . . . . . . . . . . . . . . . . . . 17
1.4.3.2 Using the MySQL Server for Free Under
GPL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
1.4.4 MySQL AB Logos and Trademarks . . . . . . . . . . . . . 18
1.4.4.1 The Original MySQL Logo. . . . . . . . . . . . . 19
1.4.4.2 MySQL Logos that may be Used Without
Written Permission . . . . . . . . . . . . . . . . . . . . . . . 19
1.4.4.3 When do you need a Written Permission to
use MySQL Logos? . . . . . . . . . . . . . . . . . . . . . . . 19
1.4.4.4 MySQL AB Partnership Logos . . . . . . . . . 20
1.4.4.5 Using the word MySQL in Printed Text or
Presentations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
1.4.4.6 Using the word MySQL in Company and
Product Names . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
1.5 MySQL 4.0 In A Nutshell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
1.5.1 Stepwise Rollout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
1.5.2 Ready for Immediate Development Use . . . . . . . . . . 21
1.5.3 Embedded MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
1.5.4 Other Features Available From MySQL 4.0.0 . . . . 21
1.5.5 Future MySQL 4.0 Features . . . . . . . . . . . . . . . . . . . . 22
ii
1.5.6 MySQL 4.1, The Following Development Release
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
1.6 MySQL Information Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
1.6.1 MySQL Portals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
1.6.2 MySQL Mailing Lists . . . . . . . . . . . . . . . . . . . . . . . . . . 23
1.6.2.1 The MySQL Mailing Lists . . . . . . . . . . . . . 23
1.6.2.2 Asking Questions or Reporting Bugs . . . . 26
1.6.2.3 How to Report Bugs or Problems . . . . . . 26
1.6.2.4 Guidelines for Answering Questions on the
Mailing List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
1.7 How Standards-compatible Is MySQL? . . . . . . . . . . . . . . . . . . . 31
1.7.1 What Standards Does MySQL Follow? . . . . . . . . . . 31
1.7.2 Running MySQL in ANSI Mode . . . . . . . . . . . . . . . . 32
1.7.3 MySQL Extensions to ANSI SQL92 . . . . . . . . . . . . . 32
1.7.4 MySQL Dierences Compared to ANSI SQL92 . . . 34
1.7.4.1 Sub- SELECT s . . . . . . . . . . . . . . . . . . . . . . . . . . 35
1.7.4.2 SELECT INTO TABLE . . . . . . . . . . . . . . . . . . . 35
1.7.4.3 Transactions and Atomic Operations . . . 36
1.7.4.4 Stored Procedures and Triggers . . . . . . . . 38
1.7.4.5 Foreign Keys . . . . . . . . . . . . . . . . . . . . . . . . . 38
1.7.4.6 Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
1.7.4.7 ` -- ' as the Start of a Comment . . . . . . . . . 40
1.7.5 Known Errors and Design Deciencies in MySQL
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
1.8 MySQL and The Future (The TODO) . . . . . . . . . . . . . . . . . . . 43
1.8.1 Things That Should be in 4.0 . . . . . . . . . . . . . . . . . . . 44
1.8.2 Things That Must be Done in the Real Near Future
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
1.8.3 Things That Have to be Done Sometime . . . . . . . . 48
1.8.4 Things we don't Have any Plans to do . . . . . . . . . . 50
2 MySQL Installation . . . . . . . . . . . . . . . . . . . . . . . 51
2.1 Quick Standard Installation of MySQL . . . . . . . . . . . . . . . . . . . 51
2.1.1 Installing MySQL on Linux . . . . . . . . . . . . . . . . . . . . . 51
2.1.2 Installing MySQL on Windows . . . . . . . . . . . . . . . . . 52
2.1.2.1 Installing the Binaries . . . . . . . . . . . . . . . . . 53
2.1.2.2 Preparing the Windows MySQL
Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
2.1.2.3 Starting the Server for the First Time . . 54
2.2 General Installation Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
2.2.1 How to Get MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
2.2.2 Operating Systems Supported by MySQL . . . . . . . 58
2.2.3 Which MySQL Version to Use . . . . . . . . . . . . . . . . . . 60
2.2.4 Installation Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
2.2.5 How and When Updates Are Released . . . . . . . . . . . 63
2.2.6 MySQL Binaries Compiled by MySQL AB . . . . . . . 64
2.2.7 Installing a MySQL Binary Distribution . . . . . . . . . 65
2.3 Installing a MySQL Source Distribution . . . . . . . . . . . . . . . . . . 68
iii
2.3.1 Quick Installation Overview . . . . . . . . . . . . . . . . . . . . 69
2.3.2 Applying Patches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
2.3.3 Typical configure Options . . . . . . . . . . . . . . . . . . . . 71
2.3.4 Installing from the Development Source Tree. . . . . 74
2.3.5 Problems Compiling? . . . . . . . . . . . . . . . . . . . . . . . . . . 75
2.3.6 MIT-pthreads Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
2.3.7 Windows Source Distribution . . . . . . . . . . . . . . . . . . . 78
2.4 Post-installation Setup and Testing . . . . . . . . . . . . . . . . . . . . . . 79
2.4.1 Problems Running mysql_install_db . . . . . . . . . . 82
2.4.2 Problems Starting the MySQL Server . . . . . . . . . . . 84
2.4.3 Starting and Stopping MySQL Automatically . . . . 86
2.5 Upgrading/Downgrading MySQL . . . . . . . . . . . . . . . . . . . . . . . . 87
2.5.1 Upgrading From Version 3.23 to Version 4.0 . . . . . 88
2.5.2 Upgrading From Version 3.22 to Version 3.23 . . . . 88
2.5.3 Upgrading from Version 3.21 to Version 3.22 . . . . . 90
2.5.4 Upgrading from Version 3.20 to Version 3.21 . . . . . 90
2.5.5 Upgrading to Another Architecture . . . . . . . . . . . . . 91
2.6 Operating System Specic Notes . . . . . . . . . . . . . . . . . . . . . . . . 92
2.6.1 Linux Notes (All Linux Versions) . . . . . . . . . . . . . . . 92
2.6.1.1 Linux Notes for Binary Distributions . . . 96
2.6.1.2 Linux x86 Notes . . . . . . . . . . . . . . . . . . . . . . 97
2.6.1.3 Linux SPARC Notes . . . . . . . . . . . . . . . . . . 98
2.6.1.4 Linux Alpha Notes . . . . . . . . . . . . . . . . . . . . 98
2.6.1.5 Linux PowerPC Notes . . . . . . . . . . . . . . . . . 98
2.6.1.6 Linux MIPS Notes . . . . . . . . . . . . . . . . . . . . 99
2.6.1.7 Linux IA64 Notes . . . . . . . . . . . . . . . . . . . . . 99
2.6.2 Windows Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
2.6.2.1 Starting MySQL on Windows 95 or
Windows 98 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
2.6.2.2 Starting MySQL on Windows NT or
Windows 2000 . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
2.6.2.3 Running MySQL on Windows . . . . . . . . . 101
2.6.2.4 Connecting to a Remote MySQL from
Windows with SSH . . . . . . . . . . . . . . . . . . . . . . 102
2.6.2.5 Splitting Data Across Dierent Disks on
Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
2.6.2.6 Compiling MySQL Clients on Windows
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
2.6.2.7 MySQL-Windows Compared to Unix
MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
2.6.3 Solaris Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
2.6.3.1 Solaris 2.7/2.8 Notes . . . . . . . . . . . . . . . . . 108
2.6.3.2 Solaris x86 Notes . . . . . . . . . . . . . . . . . . . . 109
2.6.4 BSD Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
2.6.4.1 FreeBSD Notes . . . . . . . . . . . . . . . . . . . . . . 109
2.6.4.2 NetBSD notes . . . . . . . . . . . . . . . . . . . . . . . 110
2.6.4.3 OpenBSD Notes . . . . . . . . . . . . . . . . . . . . . 111
2.6.4.4 OpenBSD 2.5 Notes . . . . . . . . . . . . . . . . . . 111
Zgłoś jeśli naruszono regulamin