iv Discovering MySQL on IBM i5/OS
4.3 Installation of the administration tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
4.3.1 Installing the server-side tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
4.3.2 Installing the MySQL GUI Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
4.3.3 Installing phpMyAdmin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
4.4 General administration tasks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
4.4.1 Starting the MySQL Database Server. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
4.4.2 Stopping the MySQL Database Server. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
4.4.3 Checking the status of the MySQL Database Server . . . . . . . . . . . . . . . . . . . . . . 69
4.4.4 Automating the starting and stopping tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
4.4.5 Enabling, maintaining, and querying logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
4.4.6 Checking the consistency of databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Chapter 5. Security, access control, and privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
5.1 The privilege system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
5.2 The privilege system of the MySQL Database Server . . . . . . . . . . . . . . . . . . . . . . . . . 88
5.3 Privileges provided by the MySQL Database Server . . . . . . . . . . . . . . . . . . . . . . . . . . 90
5.4 Creating a user, granting privileges, and revoking privileges . . . . . . . . . . . . . . . . . . . . 91
5.4.1 Executing the MySQL Database Server commands. . . . . . . . . . . . . . . . . . . . . . . 91
5.4.2 User accounts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
5.4.3 The GRANT statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
5.4.4 GRANT: Column values in the privilege tables . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
5.4.5 Scope column . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
5.4.6 Revoking privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
5.5 When privilege changes take effect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
5.6 Granting user privileges in MySQL Administrator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Chapter 6. Backup and restore of the MySQL databases . . . . . . . . . . . . . . . . . . . . . . . 99
6.1 Methods for backup and restore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
6.2 Making a backup of the MySQL Database Server . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
6.2.1 The mysqldump script for backup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
6.2.2 The mysqlhotcopy script for backup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
6.2.3 MySQL Administrator for backup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
6.2.4 phpMyAdmin for backup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
6.3 Restoring the MySQL databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
6.3.1 The mysqlimport command for restore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
6.3.2 The source command for restore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
6.3.3 MySQL Administrator for restore. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
6.3.4 phpMyAdmin for restore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
6.4 Additional tools for backup and restore. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
6.4.1 Security backup to TAPE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
6.4.2 Security backup to *SAVF. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
6.4.3 Restoring from TAPE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
6.4.4 Restoring from *SAVF. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
6.5 Common backup and restore errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
6.5.1 Additional information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
Chapter 7. Replication and clustering. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
7.1 Introduction to clustering in MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
7.2 Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
7.3 Configuring the replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
7.3.1 Creating a user for replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
7.3.2 Configuring the replication master . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
7.3.3 Configuring the replication slave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
7.3.4 Obtaining the master replication information. . . . . . . . . . . . . . . . . . . . . . . . . . . . 136