MySQL Basics for Visual Learners P ERSONAL E DITION by Kevin Jordan... MySQL Basics for Visual Learners Individuals may use this book free This Personal Edition of MySQL Basics for Vis
Trang 3MySQL Basics for Visual Learners
P ERSONAL E DITION
by Kevin Jordan
Trang 4MySQL Basics for Visual Learners
Individuals may use this book free
This Personal Edition of MySQL Basics for Visual Learners is licensed
for individual use under a Creative Commons License
Individuals may download this book for free and share it with others
However, it's illegal to sell it, or make money from it in any way No one may add pages, remove pages, or alter it
Complete license: http://creativecommons.org/licenses/by-nc-nd/2.0 Organizations must pay to use this book
Think your school or company could benefit from using this book? Tell it to buy bound copies or license this book in electronic format
Organizations, such as schools and corporations, must buy or license Visibooks for use by their students and employees However, when they do, they get the expanded Textbook Edition
The Textbook Edition is a print-quality PDF file that’s ideal for classroom use It includes extra practice exercises that work well as tests and quizzes, as well as a companion Web site
Textbook Edition available to all
Individuals and organizations who want the expanded Textbook Edition of this book can purchase it at www.visibooks.com
Trang 5TABLE OF CONTENTS i
Table of Contents
Getting Started 1
Install MySQL on a Linux computer 3
Start MySQL 14
Create a new database 24
Create a table 28
Create a record 33
Run a query 36
Administering Databases 43
Restart MySQL 44
Back up a database 47
Delete a table 56
Delete a database 58
Restore a database 59
Trang 6TABLE OF CONTENTS
ii
Working with Tables 65
Alter tables 66
Update records 69
Delete records 72
Running Queries 75
Sort query results 76
Add query criteria 85
Securing a database 91
Add a local user 92
Add a remote user 95
Remove a user 97
Restrict a user 98
Trang 9GETTING STARTED WITH MYSQL 1
Getting Started
In this section, you’ll learn how to:
• Install MySQL on a Linux computer
• Start MySQL
• Create a new database
• Create a table
• Create a record
• Run a query
Trang 10GETTING STARTED WITH MYSQL
2
What is MySQL?
MySQL is the world's most popular open-source database program
MySQL is more like Microsoft SQL Server (a server-based database program) than Access (mainly for desktop users) With MySQL running on a server, you can easily use it for business systems or database-driven websites
Easy to use and configure, MySQL is also capable of industrial-strength applications Depending on the computer it’s installed
on, MySQL can hold several terabytes of information per table
Trang 11GETTING STARTED WITH MYSQL 3
Install MySQL on a Linux computer
During Linux installation
Tip: A good version of Linux to use with this book is Mandrake
Linux
You can buy a copy on CDs at:
www.mandrakestore.com
You can also download a copy at:
www.mandrakelinux.com
If you download a copy, burn the three ISO files onto CDs
Trang 12GETTING STARTED WITH MYSQL
4
Web/FTP and Database options are selected:
Server
Web/FTP Database
This will install MySQL on your computer, along with a copy of the Apache Web server
Trang 13GETTING STARTED WITH MYSQL 5
Workstation is selected:
Graphical Environment
KDE Workstation
Trang 14GETTING STARTED WITH MYSQL
6
On an existing Linux computer
then Install Software
password in the Password box
Trang 15GETTING STARTED WITH MYSQL 7
type:
mysql
in the Search box