0% found this document useful (0 votes)
15 views

Praise For Learning MySQL

Uploaded by

Kimitake Hiraoka
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Praise For Learning MySQL

Uploaded by

Kimitake Hiraoka
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Table of Contents

Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . xiii 1. Installing MySQL. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 MySQL Forks 2 MySQL Community
Edition 2 Percona Server for MySQL 2 MariaDB Server 2 MySQL Enterprise
Edition 2 Installation Choices and Platforms 3 1. Download the Distribution
that You Want to Install 4 2. Install the Distribution 4 3. Perform Any
Necessary Post-Installation Setup 4 4. Run Benchmarks 4 Installing MySQL on
Linux 5 Installing MySQL on CentOS 7 5 Installing MySQL on CentOS 8 12
Installing MySQL on Ubuntu 20.04 LTS (Focal Fossa) 19 Installing MySQL on
macOS Big Sur 27 Installing MySQL on Windows 10 33 The Contents of the
MySQL Directory 40 MySQL 5.7 Default Files 41 MySQL 8.0 Default Files 44
Using the Command-Line Interface 44 Using Docker 45 Installing Docker 45
Using Sandboxes 50 Installing DBdeployer 51 v Using DBdeployer 51
Upgrading MySQL Server 54 2. Modeling and Designing Databases. . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 How Not to Develop a
Database 59 The Database Design Process 62 The Entity Relationship Model
62 Representing Entities 63 Representing Relationships 66 Partial and Total
Participation 67 Entity or Attribute? 68 Entity or Relationship? 70
Intermediate Entities 71 Weak and Strong Entities 72 Database Normalization
74 Normalizing an Example Table 76 First Normal Form: No Repeating Groups
76 Second Normal Form: Eliminate Redundant Data 76 Third Normal Form:
Eliminate Data Not Dependent on Key 77 Entity Relationship Modeling
Examples 77 Using the Entity Relationship Model 83 Mapping Entities and
Relationships to Database Tables 83 Creating a Bank Database ER Model 84
Converting the EER to a MySQL Database Using Workbench 85 3. Basic SQL. .
.............................................................
. . . 89 Using the sakila Database 90 The SELECT Statement and Basic
Querying Techniques 92 Single-Table SELECTs 93 Choosing Columns 94
Selecting Rows with the WHERE Clause 96 The ORDER BY Clause 105 The
LIMIT Clause 107 Joining Two Tables 109 The INSERT Statement 111 INSERT
Basics 111 Alternative Syntaxes 114 The DELETE Statement 117 DELETE
Basics 117 Using WHERE, ORDER BY, and LIMIT 118 Removing All Rows with
TRUNCATE 119 vi | Table of Contents The UPDATE Statement 120 Examples
120 Using WHERE, ORDER BY, and LIMIT 121 Exploring Databases and Tables
with SHOW and mysqlshow 121 4. Working with Database Structures. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 Creating and Using
Databases 127 Creating Tables 130 Basics 130 Collation and Character Sets
133 Other Features 135 Column Types 138 Keys and Indexes 161 The
AUTO_INCREMENT Feature 167 Altering Structures 170 Adding, Removing,
and Changing Columns 170 Adding, Removing, and Changing Indexes 174
Renaming Tables and Altering Other Structures 176 Deleting Structures 177
Dropping Databases 177 Removing Tables 178 5. Advanced Querying. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 Aliases
179 Column Aliases 180 Table Aliases 182 Aggregating Data 185 The
DISTINCT Clause 185 The GROUP BY Clause 187 The HAVING Clause 195
Advanced Joins 197 The Inner Join 197 The Union 200 The Left and Right
Joins 206 The Natural Join 211 Constant Expressions in Joins 212 Nested
Queries 215 Nested Query Basics 215 The ANY, SOME, ALL, IN, and NOT IN
Clauses 218 The EXISTS and NOT EXISTS Clauses 225 Nested Queries in the
FROM Clause 231 Table of Contents | vii Nested Queries in JOINs 233 User
Variables 234 6. Transactions and
Locking. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Isolation Levels 241 REPEATABLE READ 242 READ COMMITTED 243 READ
UNCOMMITTED 244 SERIALIZABLE 245 Locking 248 Metadata Locks 249 Row
Locks 254 Deadlocks 257 MySQL Parameters Related to Isolation and Locks
259 7. Doing More with
MySQL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
Inserting Data Using Queries 261 Loading Data from Comma-Delimited Files
267 Writing Data into Comma-Delimited Files 274 Creating Tables with
Queries 277 Performing Updates and Deletes with Multiple Tables 281
Deletion 281 Updates 286 Replacing Data 288 The EXPLAIN Statement 292
Alternative Storage Engines 297 InnoDB 300 MyISAM and Aria 301 MyRocks
and TokuDB 302 Other Table Types 304 8. Managing Users and Privileges. . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307 Understanding
Users and Privileges 307 The root User 309 Creating and Using New Users
310 Grant Tables 317 User Management Commands and Logging 319
Modifying and Dropping Users 321 Modifying a User 321 Dropping a User 325
Privileges 328 viii | Table of Contents Static Versus Dynamic Privileges 330
The SUPER Privilege 331 Privilege Management Commands 332 Checking
Privileges 335 The GRANT OPTION Privilege 337 Roles 341 Changing root’s
Password and Insecure Startup 347 Some Ideas for Secure Setup 349 9.
Using Option
Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
351 Structure of the Option File 351 Scope of Options 356 Search Order for
Option Files 359 Special Option Files 360 Login Path Configuration File 360
Persistent System Variables Configuration File 362 Determining the Options
in Effect 364 10. Backups and
Recovery. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
369 Physical and Logical Backups 370 Logical Backups 370 Physical Backups
372 Overview of Logical and Physical Backups 373 Replication as a Backup
Tool 374 Infrastructure Failure 375 Deployment Bug 375 The mysqldump
Program 376 Bootstrapping Replication with mysqldump 382 Loading Data
from a SQL Dump File 382 mysqlpump 383 mydumper and myloader 385
Cold Backup and Filesystem Snapshots 387 Percona XtraBackup 388 Backing
Up and Recovering 390 Advanced Features 393 Incremental Backups with
XtraBackup 394 Other Physical Backup Tools 396 MySQL Enterprise Backup
396 mariabackup 396 Point-in-Time Recovery 397 Technical Background on
Binary Logs 398 Table of Contents | ix Preserving Binary Logs 399 Identifying
a PITR Target 399 Point-in-Time-Recovery Example: XtraBackup 401 Point-in-
Time-Recovery Example: mysqldump 402 Exporting and Importing InnoDB
Tablespaces 402 Technical Background 403 Exporting a Tablespace 403
Importing a Tablespace 405 XtraBackup Single-Table Restore 406 Testing and
Verifying Your Backups 407 Database Backup Strategy Primer 409 11.
Configuring and Tuning the
Server. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411 The MySQL
Server Daemon 411 MySQL Server Variables 412 Checking Server Settings
412 Best Practices 413 12. Monitoring MySQL Servers. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427 Operating System Metrics 428
CPU 428 Disk 436 Memory 441 Network 446 MySQL Server Observability 450
Status Variables 451 Basic Monitoring Recipes 453 The Slow Query Log 467
InnoDB Engine Status Report 471 Investigation Methods 474 The USE Method
474 RED Method 476 MySQL Monitoring Tools 477 Incident/Diagnostic and
Manual Data Collection 482 Gathering System Status Variable Values
Periodically 483 Using pt-stalk to Collect MySQL and OS Metrics 484
Extended Manual Data Collection 485 13. High Availability. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489 Asynchronous
Replication 490 Basic Parameters to Set on the Source and the Replica 492 x
| Table of Contents Creating a Replica Using PerconaXtraBackup 493 Creating
a Replica Using the Clone Plugin 495 Creating a Replica Using mysqldump
498 Creating a Replica Using mydumper and myloader 499 Group Replication
501 Synchronous Replication 507 Galera/PXC Cluster 509 14. MySQL in the
Cloud. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
513 Database-as-a-Service (DBaaS) 513 Amazon RDS for MySQL/MariaDB
514 Google Cloud SQL for MySQL 519 Azure SQL 523 Amazon Aurora 526
MySQL Cloud Instances 527 MySQL in Kubernetes 527 Deploying Percona
XtraDB Cluster in Kubernetes 529 15. Load Balancing
MySQL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
535 Load Balancing with Application Drivers 535 ProxySQL Load Balancer
536 Installing and Configuring ProxySQL 538 HAProxy Load Balancer 542
Installing and Configuring HAProxy 543 MySQL Router 547 16. Miscellaneous
Topics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
553 MySQL Shell 553 Installing MySQL Shell 553 Installing MySQL Shell on
Ubuntu 20.04 Focal Fossa 553 Installing MySQL Shell on CentOS 8 554
Deploying a Sandbox InnoDB Cluster with MySQL Shell 555 MySQL Shell
Utilities 559 Flame Graphs 563 Building MySQL from Source 565 Building
MySQL for Ubuntu Focal Fossa and ARM Processors 566 Analyzing a MySQL
Crash 570
Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . 577

You might also like