- 5.1 连接和断开服务器5.1 Connecting to and Disconnecting from the Server
- 5.2 输入查询5.2 Entering Queries
- 5.3 创建和使用数据库5.3 Creating and Using a Database
- 5.4 获取有关数据库和表的信息5.4 Getting Information About Databases and Tables
- 5.5 在批处理模式下使用 mysql5.5 Using mysql in Batch Mode
- 5.6 常见查询示例5.6 Examples of Common Queries
- 5.6.1 某列的最大值5.6.1 The Maximum Value for a Column
- 5.6.2 某列最大值所在行5.6.2 The Row Holding the Maximum of a Certain Column
- 5.6.3 每组列的最大值5.6.3 Maximum of Column per Group
- 5.6.4 某列按组最大值所在行5.6.4 The Rows Holding the Group-wise Maximum of a Certain Column
- 5.6.5 使用用户定义的变量5.6.5 Using User-Defined Variables
- 5.6.6 使用外键5.6.6 Using Foreign Keys
- 5.6.7 在两个键上搜索5.6.7 Searching on Two Keys
- 5.6.8 每日访问量计算5.6.8 Calculating Visits Per Day
- 5.6.9 使用 AUTO_INCREMENT5.6.9 Using AUTO_INCREMENT
- 5.7 在 Apache 上使用 MySQL5.7 Using MySQL with Apache
本章通过展示如何使用 mysql 客户端程序创建和使用一个简单数据库,提供了 MySQL 的教程性介绍。mysql(有时称为 “终端监视器” 或简称 “监视器”)是一个交互式程序,使您能够连接到 MySQL 服务器、运行查询并查看结果。mysql 也可以用于批处理模式:您事先将查询放入文件中,然后告诉 mysql 执行该文件的内容。本章涵盖了这两种使用 mysql 的方法。This chapter provides a tutorial introduction to MySQL by showing how to use the mysql client program to create and use a simple database. mysql (sometimes referred to as the “terminal monitor” or just “monitor”) is an interactive program that enables you to connect to a MySQL server, run queries, and view the results. mysql may also be used in batch mode: you place your queries in a file beforehand, then tell mysql to execute the contents of the file. Both ways of using mysql are covered here.
要查看 mysql 提供的选项列表,请使用 --help 选项调用它:To see a list of options provided by mysql,
invoke it with the --help option:
$> mysql --help
本章假设 mysql 已安装在您的机器上,并且有一个 MySQL 服务器可供您连接。如果情况不是这样,请联系您的 MySQL 管理员。(如果 您 是管理员,则需要查阅本手册的相关部分,例如 第 7 章,MySQL 服务器管理。)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 Chapter 7, 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 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 information on the topics covered here.