Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 144 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
144
Dung lượng
6,33 MB
Nội dung
Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com MySQL Basicsfor Visual Learners PERSONAL EDITION by Kevin Jordan Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com MySQLBasicsforVisualLearners PERSONAL EDITION Individuals may use this book free This Personal Edition of MySQLBasicsforVisualLearners 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. Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com 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 - http://www.simpopdf.com 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 - http://www.simpopdf.com Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com 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 - http://www.simpopdf.com 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 - http://www.simpopdf.com [...]... type: mysql –u root mysql then press ENTER The window should look like this, with a mysql> prompt: 20 GETTING STARTED WITH MYSQL Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Here’s what this string of commands means: • mysqlmysql –u root mysql This first mysql starts the MySQL client MySQL is made up of two parts: the MySQL server program and a MySQL client program The MySQL. .. the MySQL server GETTING STARTED WITH MYSQL 21 Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com • mysqlmysql –u root mysql This last mysql refers to a database called mysql that you’ll use initially This database is included by default in the MySQL server The database mysql has several tables, including one that describes who can use the MySQL server 8 Type: SET PASSWORD FOR. .. of the data The MySQL client program allows you to give commands to the MySQL server You need both parts to make MySQL work • -u root mysql –u root mysql The -u command tells the MySQL client that you want to log into the MySQL server as a particular user root denotes the root user of the MySQL server You’re not logging into the Linux computer as the Root user; you’re logging into the MySQL server as... will execute it and MySQL will give an error GETTING STARTED WITH MYSQL 25 Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com 2 Type: SHOW DATABASES; then press ENTER The window should look like this: This shows the databases on your MySQL server: mysql, test, tmp, and us_presidents The other databases, mysql and tmp, are used by the MySQL server to store information about users,... password of your Linux computer It’s the root password for the MySQL server In the previous string of commands, you logged into the MySQL server as its root user, so the password textbook applies to the MySQL server You can now give commands to add/delete/modify anything in the MySQL server, but not the Linux computer it runs on GETTING STARTED WITH MYSQL 23 Simpo PDF Merge and Split Unregistered Version... should look like this: This string of commands sets the password for the root user on the MySQL server to textbook 22 GETTING STARTED WITH MYSQL Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Tip: Both the MySQL server and the Linux computer itself can have root users who can add/delete/modify anything The passwords for each are independent, however textbook is not the Root account... only work as the Root user when necessary GETTING STARTED WITH MYSQL 17 Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com 5 Next, type: /etc/rc.d/init.d /mysql start then press ENTER The window should look like this: This starts the MySQL server—the program mysql in the /etc/rc.d/init.d/ directory 18 GETTING STARTED WITH MYSQL Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com... http://www.simpopdf.com Create a new database 1 At the mysql> prompt, type: CREATE DATABASE us_presidents; then press ENTER The window should look like this: 24 GETTING STARTED WITH MYSQL Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Tip: Now that you’re logged into the MySQL server, you’re giving MySQL commands Unlike Linux commands, MySQL commands need a semicolon (;) on the end... STARTED WITH MYSQL Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com 3 When the Software Packages Installation window appears, type: mysql in the Search box Then click the button GETTING STARTED WITH MYSQL 7 Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com 4 In the Packages list, check MySQL- 4.0.15-1mdk and everything beneath it 8 GETTING STARTED WITH MYSQL Simpo... information about users, permissions, etc The test database is often used as a workplace forMySQL users to test and try things – this is useful in a work environment where many people are working with critical information 26 GETTING STARTED WITH MYSQL Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Tip: MySQL commands don’t have to be UPPER-CASE In this book, commands are put in UPPER-CASE . MySQL Basics for Visual Learners PERSONAL EDITION by Kevin Jordan Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com MySQL Basics for Visual Learners. 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. http://www.simpopdf.com 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