MYSQL TECHNICAL REFERENCE MANUAL.

Page created by Justin Green
 
CONTINUE READING
MySQL Technical Reference Manual.
  Introduction [p 5]
  General Information about MySQL [p 6]
       What is MySQL? [p 6]
       History of MySQL [p 6]
       The main features in MySQL [p 6]
       What is the current MySQL version? [p 7]
       How do I get MySQL? [p 7]
       Should I get MySQL in source or binary distribution? [p 8]
       Which operating systems does MySQL support? [p 8]
       What languages are supported by MySQL. [p 8]
       How/when will you release updates? [p 9]
       What is UNIREG ? [p 9]
       General SQL information and tutorials [p 10]
       What are stored procedurs and triggers and so on [p 10]
  MySQL mailing lists and how to ask questions [p 11]
       Subscribing to/un-subscribing from the MySQL mailing list. [p 11]
       Asking questions or reporting bugs. [p 11]
       Guidelines for answering questions on the mailing list. [p 12]
  When do I have/want to pay for MySQL? [p 13]
       How much does MySQL cost? [p 13]
       How do I get comercial support [p 14]
            Types of comercial support [p 14]
       How do I pay for a license? [p 15]
       Who do I contact when I want support/a license? [p 15]
       What Copyright does MySQL use? [p 16]
       When may I distribute MySQL commercially without a fee [p 16]
       I’m selling a product that can be configured to use MySQL [p 17]
       I am running a commercial web server using MySQL. [p 17]
       Do I need a license to sell commercial perl/tcl/PHP etc applications? [p 17]
       Possible future changes in the licensing. [p 18]
  How standards compatible are MySQL [p 19]
       What extension has MySQL to ANSI SQL92? [p 19]
       What functionality is missing in MySQL. [p 20]
       What standards does MySQL follow? [p 21]
       What functions exist only for compatibility? [p 21]
       Limitations of BLOB and TEXT types [p 21]
       How to go cope without COMMIT-ROLLBACK [p 21]
  Compiling and installing MySQL [p 24]
       Compiling MySQL [p 24]
       Problems starting MySQL [p 24]
       Automatic start/stop of MySQL [p 25]
       How to debug MySQL [p 25]
  How does MySQL privileges work [p 26]
       How does the privilege system work? [p 26]

                                                1
Adding new user privileges to MySQL [p 28]
   Default privileges. [p 28]
   A example of permission setup. [p 29]
MySQL language reference [p 30]
   Literals. How do you write strings and numbers? [p 30]
   Column types. [p 31]
         More about data types [p 33]
              Database size info. [p 33]
              The numeric types [p 33]
              TIMESTAMP type [p 33]
              TEXT and BLOB types [p 33]
              ENUM type [p 34]
              SET type [p 34]
         Column indexes [p 35]
         Multiple field indexes [p 35]
         Type mapping (to ease moving tabel definitions between different databases engines)
         [p 35]
   CREATE TABLE syntax. [p 36]
   ALTER TABLE syntax [p 37]
   DROP TABLE syntax. [p 38]
   DELETE syntax. [p 38]
   SELECT syntax [p 39]
   Functions [p 40]
   INSERT syntax [p 45]
   LOAD DATA INFILE syntax [p 45]
   UPDATE syntax [p 47]
   SHOW syntax. Get information about names of columns. [p 47]
   EXPLAIN syntax. Get information about a SELECT. [p 47]
   DESCRIBE syntax. Get information about columns. [p 48]
   Lock tables syntax [p 48]
   SET OPTION syntax. [p 48]
   GRANT syntax. (Compatibility function). [p 49]
   CREATE INDEX syntax (Compatibility function). [p 49]
   DROP INDEX syntax (Compatibility function). [p 49]
   Is MySQL picky about reserved words? [p 49]
How safe/stable is MySQL [p 52]
   How stable is MySQL? [p 52]
   Why are there is so many release of MySQL? Is it because there are so many bugs? [p 54]
   Checking a table for errors. [p 54]
   How to repair tables. [p 55]
   Is there anything special to do when upgrading/downgrading MySQL? [p 56]
How to get maximum performance out of MySQL [p 57]
   How does MySQL use memory ? [p 57]
   How does MySQL use keys? [p 58]
   How does MySQL open & close tables? [p 59]
   How should I arrange my table to be as fast/small as possible? [p 59]
   What affects the speed of the INSERT statement? [p 60]

                                            2
What affects the speed of DELETE statement? [p 60]
    What kind of optimisation is done on the WHERE clause? [p 60]
    How can I change the buffer sizes of mysqld ? [p 61]
    What options to use to get MySQL to run at full speed? [p 62]
    How to get MySQL to run as fast as possible with little memory? [p 62]
    What are the different row formats? Or when to use VARCHAR/CHAR? [p 63]
    Why so many open tables? [p 64]
MySQL Utilites [p 65]
    Overview of the different MySQL programs [p 65]
    The MySQL table check, optimize and repair program [p 66]
         Getting low level table information [p 66]
    The MySQL compressed read only table generator [p 70]
Adding functions to MySQL [p 75]
    Adding new functions to MySQL [p 75]
ODBC [p 76]
    Which operating systems does MySQL ODBC support? [p 76]
    How should I report problems with MySQL ODBC? [p 76]
    Programs known to work with MyODBC. [p 76]
    How do I fill in the various fields in the ODBC administrator program? [p 76]
Problems [p 78]
    Why do I get ’Access denied’? [p 78]
    How to run MySQL as a normal user. [p 79]
    Problems with file permissions [p 79]
    Problems using DATE fields. [p 80]
MySQL client tools and API’s [p 81]
    MySQL C API [p 81]
         Why is it that after mysql_query() returns success, mysql_store_result()
         sometimes returns NULL? [p 82]
         What results can I get from a query? [p 83]
         How can I get the unique ID for the last row? [p 83]
         What is the difference between mysql_use_result() and
         mysql_store_result() modes? [p 83]
         Problems linking with C API. [p 84]
         How to make a threadsafe client [p 84]
         Making a threadsafe client [p 84]
    What is the difference between different thread packages? [p 85]
    MySQL Perl API’s [p 85]
         mysqlperl [p 85]
         DBD::mysql [p 85]
    MySQL JAVA connectivity (JDBC) [p 85]
    MySQL C++ API’s [p 85]
    MySQL TCL API’s [p 85]
    MySQL Python API’s [p 86]
    MySQL Python API’s [p 86]
How does MySQL compare with other databases [p 87]
    How does MySQL compare with mSQL [p 87]
    How about mSQL tools like msql-tcl, msqljava? [p 88]

                                      3
How different from mSQL are the MySQL client/server communications protocols? [p 88]
         What are the differences in the SQL syntax between MySQL & mSQL 2.0? [p 89]
         Problems with AND and OR priority [p 91]

This document was generated on 3 November 1997 using the texi2html translator version 1.51
(extended by davida@detron.se).

                                                4
Go to the first, previous, next [p 6] , last [p 87] section, table of contents [p 1] .

Introduction
This is the technical manual about MySQL. This version is about the 3.21.x version of MySQL.

This document contains the basic documenatation about MySQL.

The latest version of this manual can be found at http://www.tcx.se/

This manual is currently available in TeXInfo, Raw text, Info, Postscript and HTML versions.

The primary document is the TeXInfo file. The HTML version is automatically produced with
texi2html. The ASCII and info version is produced using makeinfo. The Postscript version is
produced using texi2dvi and divps.

If you have any suggestions concerning additions or corrections, please send them to the MySQL
mailing list mysql@tcx.se withthe following subject line; documentation suggestion:
[Insert Topic Here]. See section Subscribing to/un-subscribing from the MySQL mailing list.
[p 11] .

This manual is written and maintained by David Axmark, Michael (Monty) Widenius and Kim Aldale.

Go to the first, previous, next [p 6] , last [p 87] section, table of contents [p 1] .

                                                       5
Go to the first [p 5] , previous [p 5] , next [p 11] , last [p 87] section, table of contents [p 1] .

General Information about MySQL
What is MySQL?
MySQL is a SQL (Structured Query Language) database server. SQL is the most popular database
language in the world. MySQL is a client server implementation that consists of a server daemon
mysqld and many different client programs/libraries.

The main goals of MySQL are speed and robustness.

The base upon which MySQL is built is a set of routines that have been used in a highly demanding
production environment for many years. While MySQL is currently still in development it already
offers a rich and highly useful function set. 

See the ‘CREDITS’ file in the distribution for persons that have been involved in the MySQL
project.

History of MySQL
We once started off with the intension to use mSQL to connect to our own fast low level (ISAM)
tables. However, after some testing we came to the conclusion that mSQL was not fast or flexible
enough for our needs. This resulted in a new SQL interface to our database but with almost the same
API interface as mSQL. This API was chosen to ease porting of third party code.

It is not perfectly clear where the name MySQL derives from. Our base directory and a large amount
of our libraries and tools have had the prefix ’my’ for well over 10 years. However, Monty’s daughter
(some years younger) is also named My. So which of the two gave its name to MySQL is still a
mystery, even for us.

The main features in MySQL
     Multi-threaded.
     C, C++, JAVA, Perl, Python and TCL API’s. See section MySQL client tools and API’s [p 81]
     Lots of column types like: signed/unsigned integers 1,2,3,4,8 bytes long, FLOAT, CHAR,
     VARCHAR, TEXT, BLOB, DATE, SET and ENUM types. See section Column types. [p 31]
     Join optimiser with one-sweep multi-join (all joins made in one pass).
     Full function support in the SELECT and WHERE parts. Example: select
     column1+column2 from table where column1/column2 > 0
     SQL functions are implemented through a very optimised class library and should be as fast as
     they can get! Usually there shouldn’t be any memory allocation at all after the query
     initialisation.
     Full support for SQL GROUP BY and ORDER BY. Support for group functions (SUM, MAX and
     MIN).
     A privilege and password system with is very flexible and secure. Allows host based verification.
     All password traffic on the net is encrypted.

                                                       6
Very fast B-tree disk tables with key compression.
     Fixed and variable length records.
     16 indexes/table. Each index may consist of 1 to 15 columns/parts of columns. Max key length is
     127 bytes. A key may be a prefix of a CHAR field.
     ODBC Open-DataBase-Connectivity for Windows95 (with source). All ODBC 2.5 functions and
     lots of others.
     In memory hash tables always used as temporary tables.
     Can handle big databases (we are using MySQL with some databases that contain 50,000,000
     records).
     All columns have default values. One can always use INSERT on any subset of columns.
     Uses GNU autoconf for portability.
     Written in C and C++. Tested with gcc 2.7.2.
     A thread based memory allocation system (very fast and no memory trashing).
     No memory leaks. Tested with a commercial memory leakage detector (purify).
     A very fast table check and repair utility (isamchk).
     All data saved in ISO8859_1 format. All comparisons for normal string columns are case
     insensitive.
     Full ISO8859_1 (Latin1) support. For example Scandinavian åäö is allowed in table and column
     names.
     Sorts by ISO8859_1 Latin1 (the Swedish way at the moment). It is possible to change this in the
     source by adding new sort order arrays.
     Alias on tables and columns as in the SQL92 standard. avg & count).
     INSERT,UPDATE and DELETE returns how many rows were affected.
     Function names do not clash with table or column names. For example ABS is a valid column
     name. The only restriction is that space is not allowed between a function name and the ’(’ when
     using functions.
     All MySQL commands have --help or -? for help.
     The server currently supports error messages to clients in many languages. See section What
     languages are supported by MySQL. [p 8] .
     The clients uses a TCP connection or unix socket when connecting to the MySQL server.
     User commands as show tables, show keys from table and show columns from
     table

What is the current MySQL version?
You can always check http://www.tcx.se/ for the latest version of MySQL.

How do I get MySQL?
On the Internet, try using a web browser to http://www.tcx.se/

Or ftp to ftp://ftp.sunet.se/pub/unix/databases/relational/mysql/. That isSunet’s (Swedish University
Network) FTP archive in Sweden.

                                                   7
Should I get MySQL in source or binary distribution?
If you want to read (and/or modify) the C and C++ code that makes up MySQL you should always get
a source distribution. The code is always the ultimate manual. The source distribution also contains
more tests and examples than the binary distribution.

For most people who want to run MySQL on a platform that has binary releases, a binary version of
MySQL is more convenient. However, TcX’s binary release is not compiled in the same way as the
source release so there are some differences in where support files are located.

Which operating systems does MySQL support?
We use GNU autoconf so it will be possible to port to all modern systems with working Posix threads
and a C++ compiler. The client code requires C++ but not threads. We use the software ourselves
primarily on Solaris (currently 2.5.1) and some on RedHat Linux 4.2 (kernel 2.0.30).

A working Posix thread library is needed for the server. On Solaris 2.5 we use SUN PThreads (the
native thread support in 2.4 and earlier versions are not good enough) and on Linux we use Linux
Threads by Xavier Leroy @email{Xavier.Leroy@inria.fr}.

A good web page about different thread implementations is http://www.humanfactor.com/pthreads/.

The MySQL distribution includes a patched version of Provenzano’s Pthreads from MIT (see
http://www.mit.edu:8001/people/proven/pthreads.html) in thedistribution. This can be used for some
operating systems that does not have posix threads.

We have also tried to use another user level thread package named FSU Pthreads (see
http://www.informatik.hu-berlin.de/~mueller/pthreads.html). Thisimplementation is being used for the
SCO port.

See the thr_lock and thr_alarm programs in the mysys directory for some tests/examples of these
problems. More information can be found in the ‘PORTING’ file in the distribution.

What languages are supported by MySQL.
mysqld can give error messages in the following languages: Czech, Dutch, English (default), French,
German, Norwegian, New Norwegian, Polish, Portuguese, Spanish and Swedish.

To start mysqld with a language use the --language=lang or -L lang switch:

mysqld --language swedish mysqld --language /usr/local/share/swedish

The language files are located (by default) in

‘mysql_base_dir/share/LANGUAGE/’

                                                 8
How/when will you release updates?
We are going to use the following policy when updating MySQL:

Each minor patch will increment the last number in the version string. When there are new features or
minor incompatibilities with previous versions, the second number in the version string will be
incremented.

     On the rare occasions when a fatal bug is found that can’t be avoided we will make new binary
     releases for Solaris & Linux as soon as possible. Other people may make binary releases for other
     systems but probably less frequently.
     For other fatal bugs we will make patches available as soon as we have located and fixed the bug.
     For non crucial but annoying bugs we will make patches available if they are sent to me,
     otherwise we will combine many of them into a bigger patch.
     When there are more then about 10 patches we will make a new full source release.
     When we have made a lot of changes we will make a new source and binary release. (About once
     a month?)

What is UNIREG ?
Unireg is our tty interface builder, but it uses a low level connection to our NISAM (with is used by
MySQL) and because of this it is very quick. It has existed since 1979 (on Unix in C since ~1986).

Unireg has the following components:

     One table viewer with updates/browsing.
     Multi table viewer (with 1 scrolling region)
     Table creator. (With lots of column tags you can’t create with MySQL) This is WYSIWYG (for
     a tty). You design a screen and Unireg prompts for the column specification.
     Report generator
     A lot of utilities (Quick export/import of tables to/from text files, analysis of table contents...)
     Powerful multi table updates (which we use a lot) with a BASIC like language with LOTS of
     functions.
     Dynamic languages (at present in Swedish and Finnish). If somebody wants an English version
     there are a few files that would have to be translate.
     The ability to run updates interactively or in a batch.
     Emacs like key definitions with keyboard macros.
     All this in a binary of 800k.
     The convform utility. Changes .frm and text files between different character sets.
     The pack_isam utility. Packs a NISAM table (makes it 50-80% smaller). The table can be read by
     MySQL like an ordinary table. Only 1 record has to be decompressed / access. Cannot handle
     BLOB:s or updates (yet).

We update most of our production databases with the UNIREG interface and serve web pages through
MySQL (and in some extreme cases the UNIREG report generator).

Unireg takes about 3M of disk space and works on at least the following platforms: SUN OS 4.x,
Solaris, Linux, HPUX, ICL Unix, DNIX, SCO and MSDOS.

                                                    9
Unireg is currently only available in Swedish and Finnish.

The price tag for UNIREG is 10,000 Swedish kr (about 1500$ US), but this includes support.
UNIREG is distributed as a binary. (But all the ISAM sources can be found in MySQL). Usually we
compile the binary for the customer at their site.

All new development is concentrated to MySQL.

General SQL information and tutorials
There is one SQL tutor on the net ata http://w3.one.net/~jhoffman/sqltut.htm

This one has been recommended by a lot of people on the MySQL mailing list.
Judith S. Bowman, Sandra L. Emerson and Marcy Darnovsky
"The Practical SQL Handbook: Using Structured Query Language"
Second Edition
Addison Wesley
ISBN 0-201-62623-3
http://www.awl.com

And another book also recommended by people on the MySQL mailing list.
Understanding SQL
ISBN 0-89588-644-8
Publisher Sybex 510 523 8233
Alameda CA USA

What are stored procedurs and triggers and so on
A stored procedure is a couple of SQL commands that can be stored and compiled in the server. After
this the client doesn’t have to issue the hole query but can refer to the stored procedure. This gives
some more speed because the query only have to be parsed once and there is less data that has to be
sent between the server and the client. You can also raise the conceptual level by having libraies of
functions in the server.

A trigger is a stored procedure that is invoked when something happens. For example one can install a
stored procedure that checks every delete to a transaction table and does a automatic delete on the
corresponding customer when all his transactions are deleted.

Go to the first [p 5] , previous [p 5] , next [p 11] , last [p 87] section, table of contents [p 1] .

                                                       10
Go to the first [p 5] , previous [p 6] , next [p 13] , last [p 87] section, table of contents [p 1] .

MySQL mailing lists and how to ask questions
Subscribing to/un-subscribing from the MySQL mailing list.
Requests to be added or dropped from the MySQL list should be sent to the electronic mail address
mdomo@tcx.se. Sending a one linemessage saying either subscribe mysql or un-subscribe
mysql will suffice. If your reply address is not valid you may use subscribe mysql
your@address.your-domain or un-subscribe mysql
your@address.your-domain.

Please do not send mail about [un]subscribing to mysql@tcx.se since any mail sent to this address
isautomatically forwarded to hundreds of other users.

Your local site may have many subscribers to MySQL. In that case, it may have a local mailing list,
so that a single message from tcx.se is sent to the site and propagated to the local list. In such cases,
please contact your system administrator to be added to or dropped from the local MySQL list.

Mail to mdomo is handled automatically by majordomo.

Asking questions or reporting bugs.
Before you ask a question on the mailing list it is a good idea to check in the manual. If you can’t find
an answer in the manual, check with your local MySQL expert. If you do not have any luck there,
read through this manual. If you still can’t find an answer to your question go ahead and send mail to
mysql@tcx.se.

I think I have found a bug. What information do you need to help me?

If you can, please use the mysqlbug script that can be found in the scripts directory in the
distribution. If that is not possible, remember to specify (if relevant) the following:

  1. State which version of MySQL you are using (for example mysql-3.20.0.tgz). You can find out
     which version you are running by typing mysqladmin version.
  2. The manufacturer and model of machine you are working on.
  3. The operating system. For most operating systems you can get this from uname -a.
  4. Sometimes the amount of memory (real and virtual) is also relevant.
  5. If this is a bug when compiling: Include the exact error messages and also a few lines around the
     offending code in the file from which you got the error.
  6. If this is a run time bug, please describe exactly how you got the error. If you can include a test
     program which shows the error you can get a more explicit answer.

If you are a support customer, please post the bug report to the specified mailing list for higher priority
treatment.

                                                       11
When answers are sent to you individually and not to the mailing list, it is considered good etiquette to
summarise the answers and mail them to the mailing list.

Guidelines for answering questions on the mailing list.
Try to make your answer broad enough that people other than the original poster may benefit from it.
If you consider your answer to have broad interest, you may want to post it to the mailing list instead
of replying directly to the individual who asked. In such cases, please make sure that your answer is
not a duplication of a previous answer.

Try to summarise the essential part of the question in your reply, but don’t feel obliged to quote the
whole question.

Go to the first [p 5] , previous [p 6] , next [p 13] , last [p 87] section, table of contents [p 1] .

                                                       12
Go to the first [p 5] , previous [p 11] , next [p 19] , last [p 87] section, table of contents [p 1] .

When do I have/want to pay for MySQL?
Basic licensing issues:

     The easiest way to pay for MySQL is to use the license form at TcX’s secure server at
     @url{https://www.tcx.se/license.htmy}
     We hope everybody understands that you only have to pay if you are selling MySQL directly or
     selling a product which includes the MySQL server. You may not include MySQL in a
     distribution if you charge for some part of it. For internal use you do not have to pay us if you do
     not want to.
     The client code is in the Public Domain or under the GPL (read-line). So there should not be any
     problems with client code in commercial programs.
     We may add some additional functionality in the commercial version. The likely test candidate
     for this is fast compressed read only databases. The current server includes support to read such
     databases but not the packing tool. If we get enough revenue from support we will probably
     release this under the same license as the other stuff.
     But if you like MySQL and want to encourage further development you are welcome to purchase
     a license or support.

For more information see the rest of this chapter and the file ‘PUBLIC’ in the distribution.

How much does MySQL cost?
For normal use MySQL costs nothing. When you sell MySQL directly or as a part of another product
you have to pay for it. See the file ‘PUBLIC’ in the distribution.

The client access part of MySQL is in the public domain. The command line client includes parts that
is under the GNU Public License (readline).

These are our current license prices. All prices in US Dollars. If you pay by credit card the currency is
FIM (Finish Marks) so the prices will differ slightly.

Number of licenses                                  Price/Copy                      Total
1                                                   US $200                         US $200
10 pack                                             US $150                         US $1500
50 pack                                             US $120                         US $6000

For high volume (OEM) purchases the following apply:

                                                       13
licenses            Price/Copy         Minimum at one time                 Minimum Payment
100-1000            $40                100                                 $4000
1000-2500           $25                200                                 $5000
2500-5000           $20                400                                 $8000

The OEM prices require that you act as a middle-man for eventual problems/extension requests from
users. We also require that the OEM customer has a support contract. If you have a low margin high
volume product you can always talk to us about other terms. If you do, please be informative about
your product, pricing, market and any other information that may be relevant.

How do I get comercial support
A full price license includes really basic support. This means that we are trying to answer any relevant
question. If the answer is in the documentation, we are going to direct you to the relevant
documentation. If you do not have a license/support we will probably not answer at all.

If you discover what we consider a real bug, we are likely to fix it in any case. But if you pay for
support we will notify you about the fix status instead of just fixing it in a later release.

More comprehensive support is sold separately:

Types of comercial support
‘basic email support’
   One year of basic email support costs $200. And includes
     1. For MySQL specific questions that doesn’t belong to the mysql mailing list
        (@email{mysql@tcx.se}) you can contact mysql-support@tcx.se. Remember to give your
        registration numberand expiration date when mailing any list to ensure a quick responce.
     2. We guaranty a timely answer for your mails. We can’t garanty that we can solve any
        problem, but at least you will receive an answer if we can contact you by email.
     3. Your suggestions for the further development of MySQL will be taken into consideration.
        By taking email support you have already helped the further devolpment of MySQL. If you
        want to have more input upgrade to extended support.
     4. You are entitled to upgrade to extended email support for the difference between the
        different support prices. If you have extend email support you are allowed ’sligtly alter the
        MySQL TODO’, your email will be even more prioritized and if you have a very specific
        problem we can try to log in on your system and try to solve it ’in place’.
‘extented email support’
   One year of extented email support costs $1000.
     1. For MySQL specific questions that doesn’t belong to the mysql mailing list
        (@email{mysql@tcx.se}) you can contact mysql-support@tcx.se. Remember to give your
        registration numberand expiration date when mailing any list to ensure a quick responce.
     2. We guaranty a timely answer for your mails. We can’t garanty that we can solve every
        problem, but at least you will receive an answer if we can contact you by email.
     3. Your suggestions for the further development of MySQL will be taken into consideration.
        By taking extended email support you have already helped the further devolpment of
        MySQL.

                                                    14
4. You are allowed to alter the MySQL TODO.
     5. Your email will be dealt with before normal email support users and non registred users.
     6. If you have a very specific problem we can try to log in on your system and try to solve it
        ’in place’.
‘login support’
   One year of email/phone/telnet support costs $2000. In this we include support for fast
   compressed read only databases (no blobs yet). The current server includes support to read such
   databases but not the packing tool. If we get enough revenue from support we will probably
   release this under the same license as the server sometime in the future...
‘extented login supprt’
   One year of extented email/phone/telnet support costs $5000. This of course also includes the
   compressed read only database support.

General terms for all types of support:

How do I pay for a license?
Well currently we can take SWIFT payments, cheques or credit cards.

Payment should be made to:
            Postgirot Bank AB
            105 06 STOCKHOLM, SWEDEN

            T.C.X DATAKONSULT AB
            BOX 6434
            11382 STOCKHOLM

            SWIFT address: PGSI SESS
            Account number: 96 77 06 - 3

            Specify: license and/or support and your name and email address.

In Europe and Japan you can use EuroGiro (that should be cheaper) to the same account.

If you want to pay by cheque make it payable to "Monty Program KB". And mail it to the address
below.
Monty Program KB
Michael Widenius
Gamla Skomakarbolev. 1 E 11
00740 Helsingfors
Finland

If you want to pay with credit card over Internet you can use https://www.tcx.se/license.htmy

Who do I contact when I want support/a license?
For commercial licensing or if you have any questions about any of the information in this document,
please contact:

                                                  15
Detron HB
David Axmark
Kungsgatan 65 B
753 21 UPPSALA
SWEDEN
Voice Phone +46-18-10 22 80
Fax +46-8-729 69 05 (I prefer email if possible as the fax machine happens to be in another town.)
E-Mail: mysql-c@detron.se

What Copyright does MySQL use?
There are four different copyright’s on the MySQL distribution.

 1. The MySQL specific source needed to make the mysqlclient library and programs in the
    ‘client’ directory is in the public domain. Each file which is in the public domain has a
    header which clearly states so. This is everything in ‘client’ directory and some parts of
    mysys, mystring and dbug libraries.
 2. Some small parts of the source (GNU getopt) are covered by the "GNU LIBRARY GENERAL
    PUBLIC LICENSE". See the ‘mysys/COPYING.LIB’ file.
 3. Some parts of the source (GNU readline) are covered by the "GNU GENERAL PUBLIC
    LICENSE". See the ‘readline/COPYING’ file.
 4. Some parts of the source (the regexp library) are covered by a Berkeley style copyright.
 5. The other source needed for the MySQL server is AGPL. See the file PUBLIC for more info.

Our philosophy behind this is:

     The SQL client library should be totally free so it can be included in commercial products
     without limitations.
     People who want free access to the software we have put a lot of work into can have it so long
     they do not try to make money directly by distributing it for profit.
     People who want the right to keep their own software proprietary, but also want the value from
     our work, can pay for the privilege.
     That means that normal in house use is FREE. But if you use it for something important to you,
     you may want to support further development of MySQL by purchasing a support license.

When may I distribute MySQL commercially without a fee
This is a clarification of the information in the ‘PUBLIC’ file.

MySQL may be *used* freely, including by commercial entities for evaluation or unsupported internal
use. However, *distribution* for commercial purposes of MySQL, or anything containing or derived
from MySQL in whole or in part, requires a written commercial license from TcX AB, the sole entity
authorised by to grant such licenses.

You may not include MySQL "free" in a package containing anything for which a charge is being
made except as noted below.

The intent of the exception provided in the second clause is to allow commercial organisations
operating an FTP server or a bulletin board to distribute MySQL freely from it, provided that:

                                                  16
1. The organisation complies with the other provisions of the FPL, which include among other
    things a requirement to distribute the full source code of MySQL and of any derived work, and to
    distribute the FPL itself along with MySQL;
 2. the only charge for downloading MySQL is a charge based on the distribution service and not
    one based on the content of the information being retrieved (i.e., the charge would be the same
    for retrieving a random collection of bits of the same size);
 3. the server or BBS is accessible to the general public, i.e., the phone number or IP address is not
    kept secret, and anyone may obtain access to the information (possibly by paying a subscription
    or access fee that is not dependent on or related to purchasing anything else).

If you want to distribute software in a commercial context that incorporates MySQL and you do *not*
want to meet these conditions, you should contact TcX AB to find out about commercial licensing.
Commercial licenses involve a payment, and include support and other benefits. These are the only
ways you legally can distribute MySQL or anything containing MySQL: either by distributing
MySQL under the requirements of the FPL, or by getting a commercial license from TcX AB.

I’m selling a product that can be configured to use MySQL
I’m selling a product that can be configured to use MySQL although my customer is responsible for
obtaining/installing MySQL (or some other supported alternative). Does one of us owe you money if
my customer chooses to use MySQL?

If your product REQUIRED MySQL to work you would have to pay a license. If MySQL just added
some new features it should fall inside normal use. For example is using MySQL added logging to a
database instead of a text file it should not require a license. This would of course mean that the user
has to fetch and install MySQL by himself. If the program is (almost) useless without MySQL you
would have to get a MySQL license to sell your product.

I am running a commercial web server using MySQL.
Do I have to get a license for my copy?

No you are not selling MySQL itself. But is this case we would like you to purchase MySQL support.
That is either your support of MySQL or our support of you (the later is more expensive since our
time is limited).

Do I need a license to sell commercial perl/tcl/PHP etc
applications?
Is your script designed for MySQL alone? Does it require MySQL to function at all? Or is it designed
for ‘a database’ and can run under MySQL, PostgreSQL, or something else?

If you’ve designed it strictly around MySQL then you’ve really made a commercial product that
requires the engine, so yes, I would think you have to pay.

If, however, you can support any database with a base level of functionality (and you don’t rely on
anything that only MySQL supports) you probably DO NOT have to pay.

                                                   17
It also depends on what you’re doing for the client. Are you tying into a database you expect to
already exist by the time your software is purchased? Then you again probably don’t have to pay. Or
do you plan to distribute MySQL or give them detailed instructions on installing it with your
software? Then you probably do.

One thing I’d like to suggest, folks. Look, development won’t last forever if nobody pays. I agree that
buying a copy for every software user is prohibitive compared to other products available but would it
not be courtesy for commercial developers to register their OWN copy that they develop with?

Possible future changes in the licensing.
We may choose to distribute older versions of MySQL with the GPL in the future. However these
versions will be identified as "GNU MySQL". Also all copyright notices in the relevant files will be
changed to the GPL.

Go to the first [p 5] , previous [p 11] , next [p 19] , last [p 87] section, table of contents [p 1] .

                                                       18
Go to the first [p 5] , previous [p 13] , next [p 24] , last [p 87] section, table of contents [p 1] .

How standards compatible are MySQL
What extension has MySQL to ANSI SQL92?
The following are useful extensions in MySQL that you probably will not find in other SQL:s. Be
warned that if you use this your code will not be portable to other SQL servers.

     The field types MEDIUMINT, SET, EMUN???? and the different BLOB and TEXT types.
     The field attributes auto_increment, unsigned and zerofill.
     MySQL maps all tables to filenames and with MySQL one can use standard system tools to
     backup, rename, move, delete and copy tables. This forces MySQL to be case sensitive on table
     names on operating systems that have case sensitive filenames (like most Unix systems). If you
     have a problem remembering table names, create everything in lowercase.
     Use of INTO OUTFILE and STRAIGHT_JOIN in a SELECT statement. See section SELECT
     syntax [p 39] .
     EXPLAIN SELECT to get a description on how tables are joined.
     Use of key names, keys on a subpart of a field, and use of KEY or INDEX in a CREATE TABLE
     statement. See section CREATE TABLE syntax. [p 36]
     Use of DROP column or CHANGE column in a ALTER TABLE statement. See section
     ALTER TABLE syntax [p 37] .
     Use of LOAD DATA INFILE. This syntax is in many cases compatible with Oracles LOAD
     DATA INFILE. See section LOAD DATA INFILE syntax [p 45] .
     Using " instead of ’ to enclose strings.
     Using the escape \ character.
     The SET OPTION statement. See section SET OPTION syntax. [p 48]
     Using, in the SELECT part of a GROUP BY statement, fields or functions that do not appear in
     the GROUP BY list. In MySQL this means ’any matching value’. By using this one can get a
     much higher performance by avoiding sorting and grouping unnecessary items. This is often used
     in this context:
     SELECT order.customerid,customer.name,max(payments) from order,customer
     WHERE order.customerid = customer.customerid GROUP BY order.customerid;

     In ANSI SQL you would have to add the customer.name in the GROUP BY clause which is
     redundant in MySQL.
     To make it easier for user that comes from different SQL environments mysql supports a lot of
     aliases for many functions. For example all string functions support both the ANSI SQL and the
     ODBC syntax.
     The || and && operators is in MySQL synonyms for OR and AND, like in the C programming
     language. Likewise | and & stands for bitwise OR and AND. Because if this nice syntax, MySQL
     doesn’t support the ANSI SQL operator || for string concatenation, but one have to use
     CONCAT() instead. As CONCAT() takes any number of arguments it’s easy to convert use of
     the || operatior to MySQL.
     Use of any of the following functions:
          =, , , AND, OR, or LIKE in a column statement
          LAST_INSERT_ID. See section How can I get the unique ID for the last row? [p 83]

                                                       19
REGEXP or NOT REGEXP.
         CONCAT() or CHAR() with 1 or more than 2 arguments. In MySQL the above functions
         can take any number of arguments.
         BIT_COUNT(), ELT(), FROM_DAYS(), FORMAT(), IF(), PASSWORD(),
         ENCRYPT(), PERIOD_ADD(), PERIOD_DIFF(), TO_DAYS(), or WEEKDAY().
         Use of TRIM to trim substrings. ANSI SQL only supports removal of single characters.
         The STD(), BIT_OR and BIT_AND group functions.
         Use of MIN() or MAX() as functions, not group functions.

What functionality is missing in MySQL.
The following functionality is missing in the current version of MySQL. For the priority of new
extensions you should consult: http://www.tcx.se/TODO

    Sub-SELECT. The following will not work in MySQL:
    SELECT * from table WHERE id IN (SELECT id from table2)

    MySQL only supports INSERT ... SELECT.... Independent sub-SELECTs will be
    availably in 3.22.0. One can use the function IN() in other context thought.
    MySQL doesn’t yet support sqlSELECT ... INTO TABLE..... Currentlyl MySQL only
    supports SELECT ... INTO OUTFILE....
    Outer joins. LEFT OUTER JOIN will be availabe in 3.22.0.
    Transactions is not supported. MySQL will shortly support atomic operations which is like
    transactions without rollback. With atomic operations you can make a bunch of
    insert/select/whatever commands and be guaranteed that no other thread will interfere. In this
    context you won’t usually need rollback. Currently you can do this with the help of the LOCK
    TABLES/UNLOCK TABLES command. See section Lock tables syntax [p 48]
    Triggers is not supported. The planed update language will be able to handle stored procedures,
    but without triggers. Triggers usually slow down everything, even for queries when they aren’t
    needed.
    The FOREIGN KEY syntax in MySQL exists only for compatibility with other SQL vendors
    CREATE TABLE commands: It doesn’t do anything. The FOREIGN KEY syntax without ON
    DELETE .. is mostly used for documentation purposes. Some ODBC applications may uses
    this to produce automatic WHERE clauses thought, but this is usually easy to override. FOREIGN
    KEY is sometimes used as a constraint check, but this check is in practice unnecessary if one
    insert rows in the tables in the right order. In MySQL one can go around the problem that ON
    DELETE ... isn’t implement by adding the approative DELETE statement to the application
    when one deletes record from a table that has FOREIGN KEY. In practice this is as quick (in
    some case quicker) and much more portable than using FOREING KEY Foreign keys is
    something that makes life very complicated, because the foreign key definition must be stored in
    some database and then the hole ’nice approach’ by using only files that can be moved, copied
    and removed will be destroyed. In the near future we will extend FOREIGN KEYS so that the at
    least the information will be saved and may be retrieved by mysqldump and ODBC.
    MySQL doesn’t support views, but this is on the TODO.
    Some other SQL has -- as start comment. MySQL has # as the start comment character, even if
    the MySQL command line tool removes all lines that starts with --. MySQL will not support this
    degenerated comment style because we have had many problems with automatic generated SQL
    queries that has used something like the following code:

                                                 20
UPDATE table_name SET credit=credit-!payment!

     Where instead of !payment! we automaticly insert the value of the payment. What do you think
     will happen when ’payment’ is negative ? Because 1--1 is legal in SQL, we think is terrible that
     ’--’ means start comment. If you have a sql program in a textfile that contains -- comments you
     should use
     replace " --" " #" < text-file-with-funny-comments.sql | mysql database.

     instead of the normal

     mysql database < text-file-with-funny-comments.sql

     You can also change the -- to # comments in the command file with:
     replace " --" " #" -- text-file-with-funny-comments.sql

     and change them back with:
     replace " #" " --" -- text-file-with-funny-comments.sql

What standards does MySQL follow?
Entry level SQL92. ODBC level 0-2.

What functions exist only for compatibility?
     GRANT. See section GRANT syntax. (Compatibility function). [p 49] This always succeeds. You
     should use the MySQL privilege tables. See section How does the privilege system work? [p 26]
     CREATE INDEX. See section CREATE INDEX syntax (Compatibility function). [p 49] This
     always succeeds. You should create your index with CREATE TABLE. See section CREATE
     TABLE syntax. [p 36] You can also use ALTER TABLE. See section ALTER TABLE syntax [p
     37] .
     DROP INDEX. See section DROP INDEX syntax (Compatibility function). [p 49] This always
     succeeds. You can use ALTER TABLE to drop indexes. See section ALTER TABLE syntax [p
     37] .

Limitations of BLOB and TEXT types
If you want to GROUP BY or a ORDER BY on a BLOB or TEXT field, you must make the field into a
fixed length object. The standard way to do this is with the SUBSTRING functions. If you don’t do
this only the first max_sort_length (default=1024) will considered when sorting.
SELECT comment from table order by substring(comment,20);

How to go cope without COMMIT-ROLLBACK
MySQL doesn’t support COMMIT-ROLLBACK. The problem with COMMIT-ROLLBACK is that
for it to handle this efficiently it would require a completely different table layout than MySQL uses
today. MySQL would also need extra threads that does automatic cleanups on the tables and the disk
usage space needed would be much higher. This would make MySQL about 2-4 times slower than it
is today. One of the reasons that MySQL is so much faster than almost all other SQL databases

                                                  21
(typical times are at least 2-3 times faster) is the lack of COMMIT-ROLLBACK.

For the moment, we are much more for implementing the SQL server language (stored procedures).
With this you very seldom really need COMMIT-ROLLBACK besides being able to do many more
things without losing any speed.

Loops that need transactions can normally be coded with the help of LOCK TABLES and one doesn’t
need cursors when one can update records on the fly.

We have transactions and cursors on the TODO but not quite prioritised. If it is implemented it will be
as a option to CREATE TABLE. That means that COMMIT-ROLLBACK will only work on those
tables and only those tables will be slower.

We at TcX have a greater need for a real fast database than a 100% general database. Whenever we
find a way to implement these without any speed loss we will probably do it, but for the moment there
is many more important things to do. Check the TODO for how we prioritise things at the moment.
Customers with extended mail support can alter this slightly, so things may be reprioritised.

The current problem is actually ROLLBACK. Without ROLLBACK you can do anything with LOCK
TABLES. To support ROLLBACK MySQL would had to be changed to store all old records that was
updated and revert everything back to the starting point if ROLLBACK was issued. For simple cases
this isn’t that hard to do (the current isamlog could be used for this), but if one wants to have
ROLLBACK with ALTER/DROP/CREATE TABLE it would make everything much harder to
implement.

To avoid using ROLLBACK one can do:
LOCK TABLES ...

- Test conditions.
- Update if everything is ok.

UNLOCK TABLES.

This is usually much faster, but not always. The only thing this doesn’t handle if someone does a kill
on the process...

One can also use functions to update things in one operation. By doing all updates relatively and/or
only update those fields that actually have changed one can get a very efficient application.

For example, when we are doing updates on some customer information, we only update the customer
data that has changed and only test that not any of the changed data, or data that depends on the
changed data, has changed in the original row. The test for change is down with the WHERE clause in
the UPDATE statement. If the record wasn’t updated we give the client a message: "Some of the data
you have changed has been changed by another user", and then we show the old row versus the new
row in a window. The user can then decide which version of the customer record he should use.

This gives us something like ’column locking’ but actually even better, because we only update some
of the columns with relative information. This means that a typical update statement looks something
like:

                                                   22
UPDATE tablename SET pay_back=pay_back+’relative change’

UPDATE customer set customer_date=’current_date’, address=’new address’,
phone=’new phone’, money_he_ows_us=money_he_ows+’new_money’ where
customer_id=id and address=’old address’ and phone=’old phone’;

As you can see, this is very efficient and even if another client has changed the ’money_he_ows_us’
or ’pay_back’ amount this will still work.

In many cases, users have wanted ROLLBACK and/or LOCK TABLES to manage unique identifiers
for some tables. This can be handled much more efficiently by using an AUTO_INCREMENT column
and the MySQL API function mysql_insert_id. See section How can I get the unique ID for the
last row? [p 83]

At TcX we have never had any need for row level locking as we have always been able to code around
it. I know some cases that really need row locking, but they are very few. If you want to have row
level locking you can do something like:
UPDATE table_name SET row_flag=1 WHERE id=ID ;

MySQL returns affected rows = 1 if the row was found and row_flag wasn’t 1 in the original
document. On the TODO there is GET_LOCK and RELEASE_LOCK for those that want to implement
application level locking.

Go to the first [p 5] , previous [p 13] , next [p 24] , last [p 87] section, table of contents [p 1] .

                                                       23
Go to the first [p 5] , previous [p 19] , next [p 26] , last [p 87] section, table of contents [p 1] .

Compiling and installing MySQL
Compiling MySQL
See the file ‘INSTALL-SOURCE’ in the MySQL distribution.

Problems starting MySQL
Check the log file to see if mysqld started up correctly.
cd 
tail .log

To verify that MySQL is working run the following tests:
> cd /usr/local/bin
> ./mysqlshow
+-----------+
| Databases |
+-----------+
| mysql     |
+-----------+

> ./mysqlshow mysql
Database: mysql
+--------+
| Tables |
+--------+
| db     |
| host   |
| user   |
+--------+

> ./mysql -e "select host,db,user from db" mysql
+------+--------+------+
| host | db     | user |
+------+--------+------+
| %    | test   |      |
| %    | test_% |      |
+------+--------+------+

There is also a benchmark suite so you can compare how MySQL perform on different platforms. In
the near future this will also be used to comapre MySQL to other SQL databases.
> cd bench
> run-auto-increment-test

You can also run the tests in the test subdirectory. To run ‘auto_increment.tst’:
./mysql -vf test < ./tests/auto_increment.tst

                                                       24
Expected results are shown in the file ‘./tests/auto_increment.res’.

Automatic start/stop of MySQL
To start or stop MySQL use the following commands:
scripts/mysql.server stop
scripts/mysql.server start

You might want to add these start and stop commands in the appropriate places in your /etc/rc* files
when you start using MySQL for production applications.

How to debug MySQL
If you are porting MySQL to an new system you should first try to get mysys/thr_lock and
mysys/thr_alarm to work. They shouldn’t core dump and not print any error (they also print a lot of
other information). Also see the file ‘PORTING’ in the distribution.

By starting bin/safe_mysqld with --log you will get a log in
install-directory/var/’hostname’.log (the top level database directory). This log will
contain all successful connections and all commands issued to the MySQL server.

If you have compiled MySQL with --with-debug=yes you can can also get a very informative log
with:
libexec/mysqld --debug

which makes a large log in /tmp/mysql.trace. The default debug option is
d:i:t:o,/tmp/mysql.trace.

You can get a smaller log with:
libexec/mysqld --debug=d,info,query,general:o,/tmp/mysql.trace

or an even smaller (on stdout):
libexec/mysqld --debug=d,general,query

You can get more information about the debug switches by examining the file dbug/dbug.c.

If you have a problem with mysqld that it crashes and you want this quickly solved, you should
include a trace file with your mail if possible. Trace files can be posted directly to
@email{mysql-support@tcx.se} to avoid long messages to the standard mail list. If the trace file is big
you should use ftp and send it to ftp://www.tcx.se/pub/mysql/secret/ together with a
mysqldump of any tables that you think can help to solve the problem. The context of the above
directory is hidden for outside users so no one except the TCX staff can look at what you send into it.

Go to the first [p 5] , previous [p 19] , next [p 26] , last [p 87] section, table of contents [p 1] .

                                                       25
Go to the first [p 5] , previous [p 24] , next [p 30] , last [p 87] section, table of contents [p 1] .

How does MySQL privileges work
MySQL has a advanded but non standard security/privileges system.

How does the privilege system work?
The MySQL privilege system makes sure that each user may do exactly the things that they are
supposed to be allowed to do. The system decides to grant different privileges depending on which
user connects from which host to which database. The decision is based on the contents of the three
tables in the MySQL database: user, host and db.

The grant tables privileges on rows are select, insert, update and delete.

The table and database privileges are create and drop. Create and drop are for both tables and
databases. Since a user with a drop grant can delete any table, this is the same thing as a drop grant for
the database.

Other privileges give the right to use files (for LOAD DATA INFILE and SELECT INTO OUTFILE)
and to use the administrative commands shutdown, reload, refresh and process, to get the current
process list.

The privilege tables are read into mysqld with mysqladmin reload. If the privilege tables are
empty or non-existent or if the server is started with --skip-grant-tables, full access is
granted to everyone.

You can always test your privileges with the script mysqlaccess, which Yves Carlier has provided
for the MySQL distribution. See section Why do I get ’Access denied’? [p 78]

     The host and db fields may contain a SQL regexp with chars % and _. Leaving any of these fields
     empty is equivalent to setting it to ’%’.
     A host may be localhost, a hostname, an IP number or an SQL expression. An empty host in
     the db table means any host in the host table. An empty host in the host or user table means any
     host that can create a TCP connection to your server.
     A db is the name of a database or an SQL regexp.
     An empty user field means any username will do.
     An empty password means that the entry will only be used if no password is supplied.
     The privileges from the user table are OR’ed to the db table. This means that a superuser only
     needs to be in the user table with all privilege-flags set to Y.

Everything granted in the user table is valid for every database that cannot be found in the db table.
For this reason, it might be wise to grant users (apart from superusers) privileges on a per-database
basis only.

The host table is mainly there to maintain a list of "secure" servers. At TcX host contains a list of
all machines on the local network. These are granted all privileges.

                                                       26
The connecting user’s privileges are calculated by the following algorithm:

 1. First sort all three tables by host by putting hosts without wildcards first, followed by hosts with
    wildcards and entries with host = "". Within each host, di.e. very much like GROUP BY
    Host, sort by user using the same rules. Finally, in the db table, sort by db using the same rules.
    In the steps below, we will look through the sorted tables and always use the first match found.
 2. Get the privileges for the connecting user from the db table using the first match found. Call this
    set of privileges P.
 3. If host = "" for the entry found in the db table, AND P with the privileges for the host in the
    host table, i.e. remove all privileges that are not "Y" in both. (If host  "", P is not
    affected. In suchcases, host must have matched the connecting host’s name at least partially.
    Therefor it can be assumed that the privileges found in this row match the connecting host’s
    profile.)
 4. OR (add) P with the privileges for the user from the user table, i.e. add all privileges that are
    "Y" in user.

The connecting user gets the set of privileges P.

Let’s show an example of the sorting and matching! Suppose that the user table contains this:
+-----------+----------+-
| Host      | User     | ...
+-----------+----------+-
| %         | root     | ...
| %         | jeffrey | ...
| localhost | root     | ...
| localhost |          | ...
+-----------+----------+-

Then the search order will be:

     localhost/root
     localhost/any
     any/jeffrey
     any/root

So jeffrey attempting to connect on localhost will be matched by the localhost/any line, not by
the any/jeffrey line. The first match found is used!

So if you have access problems, print out the user table, sort it by hand, and see where the match is
being made.

Here follows an example to add a user ’custom’ that can connect from hosts ’localhost’,
’server.domain’ and ’whitehouse.gov’. He wants to have password ’stupid’. The database
’bankacount’ he only want to use from ’localhost’ and the ’customer’ database he wants to be able to
reach from all three hosts.
shell> mysql mysql.
mysql> insert into users (host,user,password)
       values(’localhost’,’custom’,password(’stupid’));
mysql> insert into users (host,user,password)
       values(’server.domain’,’custom’,password(’stupid’));
mysql> insert into users (host,user,password)
       values(’whitehouse.gov’,’custom’,password(’stupid’));

                                                    27
mysql> insert into db
       (host,db,user,Select_priv,Insert_priv,Update_priv,Delete_priv,
        Create_priv,Drop_priv)
       values
       (’localhost’,’bankacount’,’custom’,’Y’,’Y’,’Y’,’Y’,’Y’,’Y’);
mysql> insert into db
       (host,db,user,Select_priv,Insert_priv,Update_priv,Delete_priv,
        Create_priv,Drop_priv)
       values
       (’%’,’customers’,’custom’,’Y’,’Y’,’Y’,’Y’,’Y’,’Y’);

You can of course also use xmysqladmin, mysql_webadmin, mysqladmin and even xmysql to
insert/change and update values in the privilege tables. You can find these utilities in the Contrib
directory.

Adding new user privileges to MySQL
To add privileges to the MySQL database:

This assumes the current user has insert privileges for the mysql db table and reload privileges. The
server (mysqld) has to be running. If it is not, start it with safe_mysqld --log &.
> mysql mysql
  insert into user values (’%’,’monty’,password(’something’),’Y’,’Y’,’Y’,’Y’,’Y’,’Y’,’Y’,’Y’,’Y’,’Y’) ;
  insert into user (host,user,password) values(’localhost’,’dummy’,") ;
  insert into user values (’%’,’admin’,",’N’,’N’,’N’,’N’,’N’,’N’,’Y’,’N’,’Y’,’Y’) ;
  quit
> mysqladmin reload

This makes three new users:

Monty
   Full superuser, but must use password when using MySQL.
admin
   Doesn’t need a password but is only allowed to use mysqladmin reload, mysqladmin
   refresh and mysqladmin processlist. May be granted individual database privileges
   through table db.
dummy
   Must be granted individual database privileges through table db.

Default privileges.
The default privileges (set in ‘scripts/mysql_install_db’) is that root can do anything. Any
user can do anything with any database whose name is ’test’ or starts with ’test_’. A normal user can’t
use mysqladmin shutdown or mysqladmin processlist. See the script
(‘scripts/mysql_install_db’) for an example on how to add other users.

The privilege tables are read into mysqld with ’mysqladmin reload’. If the privilege tables are empty
(or non-existent) full access are granted to everyone.

                                                    28
You can also read