MySQL Tutorial
MySQL Tutorial
Abstract
This is the MySQL Tutorial from the MySQL5.5Reference Manual.
Document generated on:2009-12-19(revision:18355)
Copyright©1997-2008MySQL AB,2009Sun Microsystems,Inc.All rights reserved.U.S.Government Rights-Commercial software.Government users are subject to the Sun Microsystems,Inc.standard license agreement and applicable provisions of the FAR and its supplements.Use is subject to li-cense terms.Sun,Sun Microsystems,the Sun logo,Java,Solaris,StarOffice,MySQL Enterprise Monitor2.0,MySQL logo™and MySQL™are trade-marks or registered trademarks of Sun Microsystems,Inc.in the U.S.and other countries.UNIX is a registered trademark in the U.S.and other countries, exclusively licensed through X/Open Company,Ltd.
Copyright©1997-2008MySQL AB,2009Sun Microsystems,Inc.Tous droits réservés.L'utilisation est soumise aux termes du contrat de licence.Sun, Sun Microsystems,le logo Sun,Java,Solaris,StarOffice,
MySQL Enterprise Monitor2.0,MySQL logo™et MySQL™sont des marques de fabrique ou des marques déposées de Sun Microsystems,Inc.aux Etats-Unis et dans d'autres pays.UNIX est une marque déposée aux Etats-Unis et dans d'autres pays et licenciée exlusivement par X/Open Company,Ltd.
This documentation is NOT distributed under a GPL license.Use of this documentation is subject to the following terms:You may create a printed copy of this documentation solely for your own personal use.Conversion to other formats is allowed as long as the actual content is not altered or edited in any way.You shall not publish or distribute this documentation in any form or on any media,except if you distribute the documentation in a manner sim-ilar to how Sun disseminates it(that is,electronically for download on a Web site with the software)or on a CD-ROM or similar medium,provided however that the documentation is disseminated together with the software on the same medium.Any other use,such as any dissemination of printed copies or use of this documentation,in whole or in part,in another publication,requires the prior written consent from an authorized representative of Sun Microsystems,Inc.Sun Microsystems,Inc.and MySQL AB reserve any and all rights to this documentation not expressly granted above.
For more information on the terms of this license,for details on how the MySQL documentation is buil
t and produced,or if you are interested in doing a translation,please contact the Documentation Team.
For additional licensing information,including licenses for libraries used by MySQL,see Preface,Notes,Licenses.
If you want help with using MySQL,please visit either the MySQL Forums or MySQL Mailing Lists where you can discuss your issues with other MySQL users.
For additional documentation on MySQL products,including translations of the documentation into other languages,and downloadable versions in vari-ety of formats,including HTML,CHM,and PDF formats,see MySQL Documentation Library.
Tutorial
This chapter provides a tutorial introduction to MySQL by showing how to use the mysql client program to create and use a simple
nect to a MySQL server,run queries,and view sql may also be used in batch mode:you place your queries in a file be-forehand,then tell mysql to execute the contents of the file.Both ways of using mysql are covered here.
To see a list of options provided by mysql,invoke it with the--help option:
This chapter assumes that mysql is installed on your machine and that a MySQL server is available to which you can connect.If this is not true,contact your MySQL administrator.(If you are the administrator,you need to consult the relevant portions of this manual,such as MySQL Server Administration.)
This chapter describes the entire process of setting up and using a database.If you are interested only in accessing an existing database, you may want to skip over the sections that describe how to create the database and the tables it contains.
Because this chapter is tutorial in nature,many details are necessarily omitted.Consult the relevant sections of the manual for more in-formation on the topics covered here.
Chapter1.Connecting to and Disconnecting from the Server To connect to the server,you will usually need to provide a MySQL user name when you invoke mysql and,most likely,a password.
If the server runs on a machine other than the one where you log in,you will also need to specify a host name.Contact your administrat-or to find out what connection parameters you should use to connect(that is,what host,user name,and password to use).Once you
know the proper parameters,you should be able to connect like this:
host and user represent the host name where your MySQL server is running and the user name of your MySQL account.Substitute
appropriate values for your setup.The********represents your password;enter it when mysql displays the Enter password: prompt.
If that works,you should see some introductory information followed by a mysql>prompt:
The mysql>prompt tells you that mysql is ready for you to enter commands.
If you are logging in on the same machine that MySQL is running on,you can omit the host,and simply use the following:
If,when you attempt to log in,you get an error message such as ERROR2002(HY000):C AN'T CONNECT TO LOCAL M Y SQL
SERVER THROUGH SOCKET'/TMP/MYSQL.SOCK'(2),it means that the MySQL server daemon(Unix)or service(Windows)is not
running.Consult the administrator or see the section of Installing and Upgrading MySQL that is appropriate to your operating system.
For help with other problems often encountered when trying to log in,see Common Errors When Using MySQL Programs.
Some MySQL installations allow users to connect as the anonymous(unnamed)user to the server run
ning on the local host.If this is the case on your machine,you should be able to connect to that server by invoking mysql without any options:
After you have connected successfully,you can disconnect any time by typing QUIT(or\q)at the mysql>prompt:
On Unix,you can also disconnect by pressing Control-D.
Most examples in the following sections assume that you are connected to the server.They indicate this by the mysql>prompt.
免费下载mysql
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论