Tải bản đầy đủ (.pdf) (144 trang)

MySQL Basics for Visual Learners ppt

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (6.33 MB, 144 trang )




Simpo PDF Merge and Split Unregistered Version -



Simpo PDF Merge and Split Unregistered Version -



MySQL Basics
for Visual Learners
PERSONAL EDITION



by Kevin Jordan

Simpo PDF Merge and Split Unregistered Version -



MySQL Basics for Visual Learners
PERSONAL EDITION


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:

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.

Simpo PDF Merge and Split Unregistered Version -

TABLE 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
Simpo PDF Merge and Split Unregistered Version -

TABLE 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
Simpo PDF Merge and Split Unregistered Version -
Simpo PDF Merge and Split Unregistered Version -
Simpo PDF Merge and Split Unregistered Version -

GETTING 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






Simpo PDF Merge and Split Unregistered Version -

GETTING 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.
Simpo PDF Merge and Split Unregistered Version -

GETTING STARTED WITH MYSQL



3

Install MySQL on a Linux computer

During Linux installation

1. Obtain a copy of Linux.

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.

Simpo PDF Merge and Split Unregistered Version -

GETTING STARTED WITH MYSQL



4
2. Begin installing Mandrake Linux.

3. When the Package Selection screen appears, make sure the

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.

Simpo PDF Merge and Split Unregistered Version -

GETTING STARTED WITH MYSQL



5
4. Under Graphical Environment, make sure KDE
Workstation is selected:

Graphical Environment
KDE Workstation



5. Continue with the Mandrake Linux installation.


Simpo PDF Merge and Split Unregistered Version -


GETTING STARTED WITH MYSQL



6
On an existing Linux computer

1. Click the icon, then Configuration, then Packaging,
then Install Software.



2. When the Run as Root window appears, type the Root
password in the Password box.



Simpo PDF Merge and Split Unregistered Version -

GETTING STARTED WITH MYSQL



7
3. When the Software Packages Installation window appears,
type:

mysql

in the Search box.


Then click the button.



Simpo PDF Merge and Split Unregistered Version -

GETTING STARTED WITH MYSQL



8
4. In the Packages list, check

MySQL-4.0.15-1mdk

and everything beneath it.



Simpo PDF Merge and Split Unregistered Version -

GETTING STARTED WITH MYSQL



9
5. Whenever the Additional packages needed window
appears, click the button.




6. Click the button.



7. Insert the Linux CDs as directed.


Simpo PDF Merge and Split Unregistered Version -

GETTING STARTED WITH MYSQL



10
8. In the Search box, type:

apache

and click the button.



Simpo PDF Merge and Split Unregistered Version -

GETTING STARTED WITH MYSQL




11
9. In the Packages list, check

apache-1.3.28-3mdk

and everything beneath it.



10. Whenever the Additional packages needed window
appears, click the button.




Simpo PDF Merge and Split Unregistered Version -

GETTING STARTED WITH MYSQL



12
11. Click the button.



12. Insert the Linux CDs as directed.

13. When the installation is complete, click the
button.




Simpo PDF Merge and Split Unregistered Version -

GETTING STARTED WITH MYSQL



13
14. Click the button.







Simpo PDF Merge and Split Unregistered Version -

GETTING STARTED WITH MYSQL



14
Start MySQL

1. Log in to your Linux computer using your user account.

2. Click the icon, then Terminals, then Konsole.




3. When the Konsole window opens, it should look like this:

Simpo PDF Merge and Split Unregistered Version -

GETTING STARTED WITH MYSQL



15
3. At the prompt, type:

su


then press the ENTER key on your keyboard.

The window should look like this:








Simpo PDF Merge and Split Unregistered Version -


GETTING STARTED WITH MYSQL



16
4. At the Password prompt, type:

Your Root user password


Not this particular string, of course, but the actual Root
password for the Linux computer.

Then press the ENTER key.

The window should look like this:



Simpo PDF Merge and Split Unregistered Version -

GETTING STARTED WITH MYSQL



1
7
Tip: Notice the prompt has changed from

[yourusername@localhost yourusername]$


to

[yourusername@localhost yourusername]#



There’s now a # at the end of the prompt.

$ means you’re giving Linux commands as a regular user. #
means you’re giving commands as the Root user.

On any Linux computer, there are regular users and the Root
user. Giving the su command allows you to give commands as
the “Super User,” or Root user, of the computer.

As the Root user, you can add/delete/modify any file on the
computer. A regular user can’t do this.

The Root user has the power to really mess up the computer, so
you should only work as the Root user when necessary.

Simpo PDF Merge and Split Unregistered Version -

×