manual.texi
上传用户:tsgydb
上传日期:2007-04-14
资源大小:10674k
文件大小:1883k
- Note that if you update the password in the @code{user} table directly using
- the first method, you must tell the server to re-read the grant tables (with
- @code{FLUSH PRIVILEGES}), because the change will go unnoticed otherwise.
- Once the @code{root} password has been set, thereafter you must supply that
- password when you connect to the server as @code{root}.
- You may wish to leave the @code{root} password blank so that you don't need
- to specify it while you perform additional setup or testing. However, be sure
- to set it before using your installation for any real production work.
- See the @code{scripts/mysql_install_db} script to see how it sets up
- the default privileges. You can use this as a basis to see how to
- add other users.
- If you want the initial privileges to be different than those just described
- above, you can modify @code{mysql_install_db} before you run it.
- @cindex grant tables, re-creating
- @cindex re-creating, grant tables
- To re-create the grant tables completely, remove all the @file{.frm},
- @file{.MYI}, and @file{.MYD} files in the directory containing the
- @code{mysql} database. (This is the directory named @file{mysql} under
- the database directory, which is listed when you run @code{mysqld
- --help}.) Then run the @code{mysql_install_db} script, possibly after
- editing it first to have the privileges you want.
- @strong{NOTE:} For @strong{MySQL} versions older than Version 3.22.10,
- you should NOT delete the @file{.frm} files. If you accidentally do this,
- you should copy them back from your @strong{MySQL} distribution before
- running @code{mysql_install_db}.
- @cindex privileges, adding
- @cindex adding, new user privileges
- @cindex user privileges, adding
- @findex GRANT statement
- @findex statements, GRANT
- @node Adding users, Passwords, Default privileges, Privilege system
- @section Adding New User Privileges to MySQL
- You can add users two different ways: by using @code{GRANT} statements
- or by manipulating the @strong{MySQL} grant tables directly. The
- preferred method is to use @code{GRANT} statements, because they are
- more concise and less error-prone.
- The examples below show how to use the @code{mysql} client to set up new
- users. These examples assume that privileges are set up according to the
- defaults described in the previous section. This means that to make changes,
- you must be on the same machine where @code{mysqld} is running, you must
- connect as the @strong{MySQL} @code{root} user, and the @code{root} user must
- have the @strong{insert} privilege for the @code{mysql} database and the
- @strong{reload} administrative privilege. Also, if you have changed the
- @code{root} user password, you must specify it for the @code{mysql} commands
- below.
- You can add new users by issuing @code{GRANT} statements:
- @example
- shell> mysql --user=root mysql
- mysql> GRANT ALL PRIVILEGES ON *.* TO monty@@localhost
- IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
- mysql> GRANT ALL PRIVILEGES ON *.* TO monty@@"%"
- IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
- mysql> GRANT RELOAD,PROCESS ON *.* TO admin@@localhost;
- mysql> GRANT USAGE ON *.* TO dummy@@localhost;
- @end example
- These @code{GRANT} statements set up three new users:
- @table @code
- @item monty
- A full superuser who can connect to the server from anywhere, but who must
- use a password @code{'some_pass'} to do so. Note that we must issue
- @code{GRANT} statements for both @code{monty@@localhost} and
- @code{monty@@"%"}. If we don't add the entry with @code{localhost}, the
- anonymous user entry for @code{localhost} that is created by
- @code{mysql_install_db} will take precedence when we connect from the local
- host, because it has a more specific @code{Host} field value and thus comes
- earlier in the @code{user} table sort order.
- @item admin
- A user who can connect from @code{localhost} without a password and who is
- granted the @strong{reload} and @strong{process} administrative privileges.
- This allows the user to execute the @code{mysqladmin reload},
- @code{mysqladmin refresh}, and @code{mysqladmin flush-*} commands, as well as
- @code{mysqladmin processlist} . No database-related privileges are granted.
- (They can be granted later by issuing additional @code{GRANT} statements.)
- @item dummy
- A user who can connect without a password, but only from the local host. The
- global privileges are all set to @code{'N'} --- the @code{USAGE} privilege
- type allows you to create a user with no privileges. It is assumed that you
- will grant database-specific privileges later.
- @end table
- @findex INSERT statement, grant privileges
- @findex statements, INSERT
- You can also add the same user access information directly by issuing
- @code{INSERT} statements and then telling the server to reload the grant
- tables:
- @example
- shell> mysql --user=root mysql
- mysql> INSERT INTO user VALUES('localhost','monty',PASSWORD('some_pass'),
- 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y')
- mysql> INSERT INTO user VALUES('%','monty',PASSWORD('some_pass'),
- 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y')
- mysql> INSERT INTO user SET Host='localhost',User='admin',
- Reload_priv='Y', Process_priv='Y';
- mysql> INSERT INTO user (Host,User,Password)
- VALUES('localhost','dummy','');
- mysql> FLUSH PRIVILEGES;
- @end example
- Depending on your @strong{MySQL} version, you may have to use a different
- number of @code{'Y'} values above (versions prior to Version 3.22.11 had fewer
- privilege columns). For the @code{admin} user, the more readable extended
- @code{INSERT} syntax that is available starting with Version 3.22.11 is used.
- Note that to set up a superuser, you need only create a @code{user} table
- entry with the privilege fields set to @code{'Y'}. No @code{db} or
- @code{host} table entries are necessary.
- The privilege columns in the @code{user} table were not set explicitly in the
- last @code{INSERT} statement (for the @code{dummy} user), so those columns
- are assigned the default value of @code{'N'}. This is the same thing that
- @code{GRANT USAGE} does.
- The following example adds a user @code{custom} who can connect from hosts
- @code{localhost}, @code{server.domain}, and @code{whitehouse.gov}. He wants
- to access the @code{bankaccount} database only from @code{localhost},
- the @code{expenses} database only from @code{whitehouse.gov}, and
- the @code{customer} database from all three hosts. He wants
- to use the password @code{stupid} from all three hosts.
- To set up this user's privileges using @code{GRANT} statements, run these
- commands:
- @example
- shell> mysql --user=root mysql
- mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
- ON bankaccount.*
- TO custom@@localhost
- IDENTIFIED BY 'stupid';
- mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
- ON expenses.*
- TO custom@@whitehouse.gov
- IDENTIFIED BY 'stupid';
- mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
- ON customer.*
- TO custom@@'%'
- IDENTIFIED BY 'stupid';
- @end example
- To set up the user's privileges by modifying the grant tables directly,
- run these commands (note the @code{FLUSH PRIVILEGES} at the end):
- @example
- shell> mysql --user=root mysql
- mysql> INSERT INTO user (Host,User,Password)
- VALUES('localhost','custom',PASSWORD('stupid'));
- mysql> INSERT INTO user (Host,User,Password)
- VALUES('server.domain','custom',PASSWORD('stupid'));
- mysql> INSERT INTO user (Host,User,Password)
- VALUES('whitehouse.gov','custom',PASSWORD('stupid'));
- mysql> INSERT INTO db
- (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,
- Create_priv,Drop_priv)
- VALUES
- ('localhost','bankaccount','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
- ('whitehouse.gov','expenses','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('%','customer','custom','Y','Y','Y','Y','Y','Y');
- mysql> FLUSH PRIVILEGES;
- @end example
- The first three @code{INSERT} statements add @code{user} table entries that
- allow user @code{custom} to connect from the various hosts with the given
- password, but grant no permissions to him (all privileges are set to the
- default value of @code{'N'}). The next three @code{INSERT} statements add
- @code{db} table entries that grant privileges to @code{custom} for the
- @code{bankaccount}, @code{expenses}, and @code{customer} databases, but only
- when accessed from the proper hosts. As usual, when the grant tables are
- modified directly, the server must be told to reload them (with
- @code{FLUSH PRIVILEGES}) so that the privilege changes take effect.
- If you want to give a specific user access from any machine in a given
- domain, you can issue a @code{GRANT} statement like the following:
- @example
- mysql> GRANT ...
- ON *.*
- TO myusername@@"%.mydomainname.com"
- IDENTIFIED BY 'mypassword';
- @end example
- To do the same thing by modifying the grant tables directly, do this:
- @example
- mysql> INSERT INTO user VALUES ('%.mydomainname.com', 'myusername',
- PASSWORD('mypassword'),...);
- mysql> FLUSH PRIVILEGES;
- @end example
- You can also use @code{xmysqladmin}, @code{mysql_webadmin}, and even
- @code{xmysql} to insert, change, and update values in the grant tables.
- You can find these utilities in the
- @uref{http://www.mysql.com/Downloads/Contrib/,Contrib directory of the @strong{MySQL}
- Website}.
- @cindex passwords, setting
- @findex PASSWORD()
- @findex SET PASSWORD statement
- @cindex setting, passwords
- @node Passwords, Access denied, Adding users, Privilege system
- @section Setting Up Passwords
- In most cases you should use @code{GRANT} to set up your users/passwords,
- so the following only applies for advanced users. @xref{GRANT, , @code{GRANT}}.
- The examples in the preceding sections illustrate an important principle:
- when you store a non-empty password using @code{INSERT} or @code{UPDATE}
- statements, you must use the @code{PASSWORD()} function to encrypt it. This
- is because the @code{user} table stores passwords in encrypted form, not as
- plaintext. If you forget that fact, you are likely to attempt to set
- passwords like this:
- @example
- shell> mysql -u root mysql
- mysql> INSERT INTO user (Host,User,Password)
- VALUES('%','jeffrey','biscuit');
- mysql> FLUSH PRIVILEGES;
- @end example
- The result is that the plaintext value @code{'biscuit'} is stored as the
- password in the @code{user} table. When the user @code{jeffrey} attempts to
- connect to the server using this password, the @code{mysql} client encrypts
- it with @code{PASSWORD()} and sends the result to the server. The server
- compares the value in the @code{user} table (the encrypted value of
- @code{'biscuit'}) to the encrypted password (which is @emph{not}
- @code{'biscuit'}). The comparison fails and the server rejects the
- connection:
- @example
- shell> mysql -u jeffrey -pbiscuit test
- Access denied
- @end example
- Passwords must be encrypted when they are inserted in the @code{user}
- table, so the @code{INSERT} statement should have been specified like this
- instead:
- @example
- mysql> INSERT INTO user (Host,User,Password)
- VALUES('%','jeffrey',PASSWORD('biscuit'));
- @end example
- You must also use the @code{PASSWORD()} function when you use @code{SET
- PASSWORD} statements:
- @example
- mysql> SET PASSWORD FOR jeffrey@@"%" = PASSWORD('biscuit');
- @end example
- If you set passwords using the @code{GRANT ... IDENTIFIED BY} statement
- or the @code{mysqladmin password} command, the @code{PASSWORD()} function
- is unnecessary. They both take care of encrypting the password for you,
- so you would specify a password of @code{'biscuit'} like this:
- @example
- mysql> GRANT USAGE ON *.* TO jeffrey@@"%" IDENTIFIED BY 'biscuit';
- @end example
- or
- @example
- shell> mysqladmin -u jeffrey password biscuit
- @end example
- @strong{NOTE:} @code{PASSWORD()} does not perform password encryption in the
- same way that Unix passwords are encrypted. You should not assume that if
- your Unix password and your @strong{MySQL} password are the same, that
- @code{PASSWORD()} will result in the same encrypted value as is stored in the
- Unix password file. @xref{User names}.
- @node Access denied, , Passwords, Privilege system
- @section Causes of @code{Access denied} Errors
- If you encounter @code{Access denied} errors when you try to connect to the
- @strong{MySQL} server, the list below indicates some courses of
- action you can take to correct the problem:
- @itemize @bullet
- @item
- After installing @strong{MySQL}, did you run the @code{mysql_install_db}
- script to set up the initial grant table contents? If not, do so.
- @xref{Default privileges}. Test the initial privileges by executing
- this command:
- @example
- shell> mysql -u root test
- @end example
- The server should let you connect without error. You should also make sure
- you have a file @file{user.MYD} in the @strong{MySQL} database directory.
- Ordinarily, this is @file{PATH/var/mysql/user.MYD}, where @code{PATH} is the
- pathname to the @strong{MySQL} installation root.
- @item
- After a fresh installation, you should connect to the server and set up
- your users and their access permissions:
- @example
- shell> mysql -u root mysql
- @end example
- The server should let you connect because the @strong{MySQL} @code{root} user
- has no password initially. That is also a security risk, so setting the
- @code{root} password is something you should do while you're setting up
- your other @strong{MySQL} users.
- If you try to connect as @code{root} and get this error:
- @example
- Access denied for user: '@@unknown' to database mysql
- @end example
- this means that you don't have an entry in the @code{user} table with a
- @code{User} column value of @code{'root'} and that @code{mysqld} cannot
- resolve the hostname for your client. In this case, you must restart the
- server with the @code{--skip-grant-tables} option and edit your
- @file{/etc/hosts} or @file{windowshosts} file to add an entry for your
- host.
- @item
- If you get an error like the following:
- @example
- shell> mysqladmin -u root -pxxxx ver
- Access denied for user: 'root@@localhost' (Using password: YES)
- @end example
- It means that you are using a wrong password. @xref{Passwords}.
- If you have forgot the root password, you can restart @code{mysqld} with
- @code{--skip-grant-tables} to change the password. You can find more
- about this option later on in this manual section.
- If you get the above error even if you haven't specified a password,
- this means that you a wrong password in some @code{my.ini}
- file. @xref{Option files}. You can avoid using option files with the @code{--no-defaults} option, as follows:
- @example
- shell> mysqladmin --no-defaults -u root ver
- @end example
- @item
- @cindex @code{mysql_fix_privilege_tables}
- If you updated an existing @strong{MySQL} installation from a version earlier
- than Version 3.22.11 to Version 3.22.11 or later, did you run the
- @code{mysql_fix_privilege_tables} script? If not, do so. The structure of
- the grant tables changed with @strong{MySQL} Version 3.22.11 when the
- @code{GRANT} statement became functional.
- @item
- If your privileges seem to have changed in the middle of a session, it may be
- that a superuser has changed them. Reloading the grant tables affects new
- client connections, but it also affects existing connections as indicated in
- @ref{Privilege changes}.
- @item
- If you can't get your password to work, remember that you must use
- the @code{PASSWORD()} function if you set the password with the
- @code{INSERT}, @code{UPDATE}, or @code{SET PASSWORD} statements. The
- @code{PASSWORD()} function is unnecessary if you specify the password using
- the @code{GRANT ... INDENTIFIED BY} statement or the @code{mysqladmin
- password} command.
- @xref{Passwords}.
- @item
- @code{localhost} is a synonym for your local hostname, and is also the
- default host to which clients try to connect if you specify no host
- explicitly. However, connections to @code{localhost} do not work if you are
- running on a system that uses MIT-pthreads (@code{localhost} connections are
- made using Unix sockets, which are not supported by MIT-pthreads). To avoid
- this problem on such systems, you should use the @code{--host} option to name
- the server host explicitly. This will make a TCP/IP connection to the
- @code{mysqld} server. In this case, you must have your real hostname in
- @code{user} table entries on the server host. (This is true even if you are
- running a client program on the same host as the server.)
- @item
- If you get an @code{Access denied} error when trying to connect to the
- database with @code{mysql -u user_name db_name}, you may have a problem
- with the @code{user} table. Check this by executing @code{mysql -u root
- mysql} and issuing this SQL statement:
- @example
- mysql> SELECT * FROM user;
- @end example
- The result should include an entry with the @code{Host} and @code{User}
- columns matching your computer's hostname and your @strong{MySQL} user name.
- @item
- The @code{Access denied} error message will tell you who you are trying
- to log in as, the host from which you are trying to connect, and whether
- or not you were using a password. Normally, you should have one entry in
- the @code{user} table that exactly matches the hostname and user name
- that were given in the error message. For example if you get an error
- message that contains @code{Using password: NO}, this means that you
- tried to login without an password.
- @item
- If you get the following error when you try to connect from a different host
- than the one on which the @strong{MySQL} server is running, then there is no
- row in the @code{user} table that matches that host:
- @example
- Host ... is not allowed to connect to this MySQL server
- @end example
- You can fix this by using the command-line tool @code{mysql} (on the
- server host!) to add a row to the @code{user}, @code{db}, or @code{host}
- table for the user/hostname combination from which you are trying to
- connect and then execute @code{mysqladmin flush-privileges}. If you are
- not running @strong{MySQL} Version 3.22 and you don't know the IP number or
- hostname of the machine from which you are connecting, you should put an
- entry with @code{'%'} as the @code{Host} column value in the @code{user}
- table and restart @code{mysqld} with the @code{--log} option on the
- server machine. After trying to connect from the client machine, the
- information in the @strong{MySQL} log will indicate how you really did
- connect. (Then replace the @code{'%'} in the @code{user} table entry
- with the actual hostname that shows up in the log. Otherwise, you'll
- have a system that is insecure.)
- Another reason for this error on Linux is that you are using a binary
- @strong{MySQL} version that is compiled with a different glibc version
- than the one you are using. In this case you should either upgrade your
- OS/glibc or download the source @strong{MySQL} version and compile this
- yourself. A source RPM is normally trivial to compile and install, so
- this isn't a big problem.
- @item
- If you get an error message where the hostname is not shown or where the
- hostname is an IP, even if you try to connect with a hostname:
- @example
- shell> mysqladmin -u root -pxxxx -h some-hostname ver
- Access denied for user: 'root@' (Using password: YES)
- @end example
- This means that @strong{MySQL} got some error when trying to resolve the
- IP to a hostname. In this case you can execute @code{mysqladmin
- flush-hosts} to reset the internal DNS cache. @xref{DNS}.
- Some permanent solutions are:
- @itemize @minus
- @item
- Try to find out what is wrong with your DNS server and fix this.
- @item
- Specify IPs instead of hostnames in the @strong{MySQL} privilege tables.
- @item
- Start mysqld with @code{--skip-name-resolve}.
- @item
- Start mysqld with @code{--skip-host-cache}.
- @item
- Connect to @code{localhost} if you are running the server and the client
- on the same machine.
- @item
- Put the client machine names in @code{/etc/hosts}.
- @end itemize
- @item
- If @code{mysql -u root test} works but @code{mysql -h your_hostname -u root
- test} results in @code{Access denied}, then you may not have the correct name
- for your host in the @code{user} table. A common problem here is that the
- @code{Host} value in the user table entry specifies an unqualified hostname,
- but your system's name resolution routines return a fully qualified domain
- name (or vice-versa). For example, if you have an entry with host
- @code{'tcx'} in the @code{user} table, but your DNS tells @strong{MySQL} that
- your hostname is @code{'tcx.subnet.se'}, the entry will not work. Try adding
- an entry to the @code{user} table that contains the IP number of your host as
- the @code{Host} column value. (Alternatively, you could add an entry to the
- @code{user} table with a @code{Host} value that contains a wild card---for
- example, @code{'tcx.%'}. However, use of hostnames ending with @samp{%} is
- @emph{insecure} and is @emph{not} recommended!)
- @item
- If @code{mysql -u user_name test} works but @code{mysql -u user_name
- other_db_name} doesn't work, you don't have an entry for @code{other_db_name}
- listed in the @code{db} table.
- @item
- If @code{mysql -u user_name db_name} works when executed on the server
- machine, but @code{mysql -u host_name -u user_name db_name} doesn't work when
- executed on another client machine, you don't have the client machine listed
- in the @code{user} table or the @code{db} table.
- @item
- If you can't figure out why you get @code{Access denied}, remove from the
- @code{user} table all entries that have @code{Host} values containing
- wild cards (entries that contain @samp{%} or @samp{_}). A very common error
- is to insert a new entry with @code{Host}=@code{'%'} and
- @code{User}=@code{'some user'}, thinking that this will allow you to specify
- @code{localhost} to connect from the same machine. The reason that this
- doesn't work is that the default privileges include an entry with
- @code{Host}=@code{'localhost'} and @code{User}=@code{''}. Because that entry
- has a @code{Host} value @code{'localhost'} that is more specific than
- @code{'%'}, it is used in preference to the new entry when connecting from
- @code{localhost}! The correct procedure is to insert a second entry with
- @code{Host}=@code{'localhost'} and @code{User}=@code{'some_user'}, or to
- remove the entry with @code{Host}=@code{'localhost'} and
- @code{User}=@code{''}.
- @item
- If you get the following error, you may have a problem with the @code{db} or
- @code{host} table:
- @example
- Access to database denied
- @end example
- If the entry selected from the @code{db} table has an empty value in the
- @code{Host} column, make sure there are one or more corresponding entries in
- the @code{host} table specifying which hosts the @code{db} table entry
- applies to.
- If you get the error when using the SQL commands @code{SELECT ...
- INTO OUTFILE} or @code{LOAD DATA INFILE}, your entry in the @code{user} table
- probably doesn't have the @strong{file} privilege enabled.
- @item
- @cindex configuration files
- @cindex environment variables
- @tindex .my.cnf file
- Remember that client programs will use connection parameters specified
- in configuration files or environment variables. @xref{Environment
- variables}. If a client seems to be sending the wrong default
- connection parameters when you don't specify them on the command line,
- check your environment and the @file{.my.cnf} file in your home
- directory. You might also check the system-wide @strong{MySQL}
- configuration files, though it is far less likely that client connection
- parameters will be specified there. @xref{Option files}. If you get
- @code{Access denied} when you run a client without any options, make
- sure you haven't specified an old password in any of your option files!
- @xref{Option files}.
- @item
- If you make changes to the grant tables directly (using an @code{INSERT} or
- @code{UPDATE} statement) and your changes seem to be ignored, remember
- that you must issue a @code{FLUSH PRIVILEGES} statement or execute a
- @code{mysqladmin flush-privileges} command to cause the server to re-read
- the privilege tables. Otherwise your changes have no effect until the
- next time the server is restarted. Remember that after you set the
- @code{root} password with an @code{UPDATE} command, you won't need to
- specify it until after you flush the privileges, because the server
- won't know you've changed the password yet!
- @item
- If you have access problems with a Perl, PHP, Python, or ODBC program, try to
- connect to the server with @code{mysql -u user_name db_name} or @code{mysql
- -u user_name -pyour_pass db_name}. If you are able to connect using the
- @code{mysql} client, there is a problem with your program and not with the
- access privileges. (Note that there is no space between @code{-p} and the
- password; you can also use the @code{--password=your_pass} syntax to specify
- the password. If you use the @code{-p} option alone, MySQL will prompt you
- for the password.)
- @item
- For testing, start the @code{mysqld} daemon with the
- @code{--skip-grant-tables} option. Then you can change the @strong{MySQL}
- grant tables and use the @code{mysqlaccess} script to check whether or not
- your modifications have the desired effect. When you are satisfied with your
- changes, execute @code{mysqladmin flush-privileges} to tell the @code{mysqld}
- server to start using the new grant tables. @strong{Note:} Reloading the
- grant tables overrides the @code{--skip-grant-tables} option. This allows
- you to tell the server to begin using the grant tables again without bringing
- it down and restarting it.
- @item
- If everything else fails, start the @code{mysqld} daemon with a debugging
- option (for example, @code{--debug=d,general,query}). This will print host and
- user information about attempted connections, as well as information about
- each command issued. @xref{Debugging server}.
- @item
- If you have any other problems with the @strong{MySQL} grant tables and
- feel you must post the problem to the mailing list, always provide a
- dump of the @strong{MySQL} grant tables. You can dump the tables with
- the @code{mysqldump mysql} command. As always, post your problem using
- the @code{mysqlbug} script. @xref{Bug reports}. In some cases you may need
- to restart @code{mysqld} with @code{--skip-grant-tables} to run
- @code{mysqldump}.
- @end itemize
- @node Reference, Table types, Privilege system, Top
- @chapter MySQL Language Reference
- @menu
- * Literals:: Literals: how to write strings and numbers
- * Variables:: User variables
- * Column types:: Column types
- * Functions:: Functions
- * CREATE DATABASE:: @code{CREATE DATABASE} syntax
- * DROP DATABASE:: @code{DROP DATABASE} syntax
- * CREATE TABLE:: @code{CREATE TABLE} syntax
- * ALTER TABLE:: @code{ALTER TABLE} syntax
- * RENAME TABLE:: @code{RENAME TABLE} syntax
- * DROP TABLE:: @code{DROP TABLE} syntax
- * OPTIMIZE TABLE:: @code{OPTIMIZE TABLE} syntax
- * CHECK TABLE:: @code{CHECK TABLE} syntax
- * BACKUP TABLE:: @code{BACKUP TABLE} syntax
- * RESTORE TABLE:: @code{RESTORE TABLE} syntax
- * ANALYZE TABLE:: @code{ANALYZE TABLE} syntax
- * REPAIR TABLE:: @code{REPAIR TABLE} syntax
- * DELETE:: @code{DELETE} syntax
- * TRUNCATE:: @code{TRUNCATE} syntax
- * SELECT:: @code{SELECT} syntax
- * JOIN:: @code{JOIN} syntax
- * INSERT:: @code{INSERT} syntax
- * REPLACE:: @code{REPLACE} syntax
- * LOAD DATA:: @code{LOAD DATA INFILE} syntax
- * UPDATE:: @code{UPDATE} syntax
- * USE:: @code{USE} syntax
- * FLUSH:: @code{Flush} syntax (clearing caches)
- * KILL:: @code{KILL} syntax
- * SHOW:: @code{SHOW} syntax (Get information about tables, columns, ...)
- * EXPLAIN:: @code{EXPLAIN} syntax (Get information about a @code{SELECT})
- * DESCRIBE:: @code{DESCRIBE} syntax (Get information about names of columns)
- * COMMIT:: @code{BEGIN/COMMIT/ROLLBACK} syntax
- * LOCK TABLES:: @code{LOCK TABLES/UNLOCK TABLES} syntax
- * SET OPTION:: @code{SET OPTION} syntax
- * GRANT:: @code{GRANT} and @code{REVOKE} syntax
- * CREATE INDEX:: @code{CREATE INDEX} syntax
- * DROP INDEX:: @code{DROP INDEX} syntax
- * Comments:: Comment syntax
- * CREATE FUNCTION:: @code{CREATE FUNCTION} syntax
- * Reserved words:: Is @strong{MySQL} picky about reserved words?
- @end menu
- @cindex strings, defined
- @cindex strings, escaping characters
- @cindex literals
- @cindex escape characters
- @cindex backslash, escape character
- @node Literals, Variables, Reference, Reference
- @section Literals: How to Write Strings and Numbers
- @menu
- * String syntax:: Strings
- * Number syntax:: Numbers
- * Hexadecimal values:: Hexadecimal values
- * NULL values:: @code{NULL} values
- * Legal names:: Database, table, index, column and alias names
- @end menu
- @node String syntax, Number syntax, Literals, Literals
- @subsection Strings
- A string is a sequence of characters, surrounded by either single quote
- (@samp{'}) or double quote (@samp{"}) characters (only the single quote
- if you run in ANSI mode). Examples:
- @example
- 'a string'
- "another string"
- @end example
- Within a string, certain sequences have special meaning. Each of these
- sequences begins with a backslash (@samp{}), known as the @emph{escape
- character}. @strong{MySQL} recognizes the following escape sequences:
- @c these aren't really functions, but that's probably the most reasonable index
- @table @code
- @findex