Table of Contents for
Mastering phpMyAdmin 3.4 for Effective MySQL Management

Version ebook / Retour

Cover image for bash Cookbook, 2nd Edition Mastering phpMyAdmin 3.4 for Effective MySQL Management by Marc Delisle Published by Packt Publishing, 2012
  1. Cover
  2. Mastering phpMyAdmin 3.4 for Effective MySQL Management
  3. Mastering phpMyAdmin 3.4 for Effective MySQL Management
  4. Credits
  5. About the Author
  6. About the Reviewers
  7. www.PacktPub.com
  8. Preface
  9. What you need for this book
  10. Who this book is for
  11. Conventions
  12. Reader feedback
  13. Customer support
  14. 1. Getting Started with phpMyAdmin
  15. What is phpMyAdmin?
  16. Installing phpMyAdmin
  17. Configuring phpMyAdmin
  18. Installing phpMyAdmin configuration storage
  19. Upgrading phpMyAdmin
  20. Summary
  21. 2. Configuring Authentication and Security
  22. Securing phpMyAdmin
  23. Summary
  24. 3. Over Viewing the Interface
  25. Customizing general settings
  26. Character sets and collations
  27. Navigation panel
  28. Main panel
  29. User preferences
  30. Query window
  31. Summary
  32. 4. Creating and Browsing Tables
  33. Creating our first table
  34. Inserting data manually
  35. Browse mode
  36. Profiling queries
  37. Creating an additional table
  38. Summary
  39. 5. Changing Data and Structure
  40. Changing table structure
  41. Summary
  42. 6. Exporting Structure and Data (Backup)
  43. Exporting a database
  44. Exporting a table
  45. Exporting selectively
  46. Exporting multiple databases
  47. Saving the export file on the server
  48. Memory limits
  49. Summary
  50. 7. Importing Structure and Data
  51. Importing SQL files
  52. Importing CSV files
  53. Importing other formats
  54. Reading files from a web server upload directory
  55. Displaying an upload progress bar
  56. Summary
  57. 8. Searching Data
  58. Performing a complete database search
  59. Stopping an errant query
  60. Summary
  61. 9. Performing Table and Database Operations
  62. Changing table attributes
  63. Emptying or deleting a table
  64. Renaming, moving, and copying tables
  65. Performing other table operations
  66. Multi-table operations
  67. Database operations
  68. Summary
  69. 10. Benefiting from the Relational System
  70. Defining relations with the relation view
  71. Defining relations with the Designer
  72. Benefiting from the defined relations
  73. Column commenting
  74. Summary
  75. 11. Entering SQL Statements
  76. The Query window
  77. Multi-statement queries
  78. Pretty printing (syntax highlighting)
  79. The SQL Validator
  80. Summary
  81. 12. Generating Multi-table Queries
  82. Exploring column criteria
  83. Generating automatic joins (internal relations)
  84. Executing the query
  85. The visual builder
  86. Summary
  87. 13. Synchronizing Data and Supporting Replication
  88. Supporting MySQL replication
  89. Summary
  90. 14. Using Query Bookmarks
  91. Creating bookmarks
  92. Recalling bookmarks from the bookmarks list
  93. Passing a parameter to a bookmark
  94. Summary
  95. 15. Documenting the System
  96. Generating relational schemas
  97. Summary
  98. 16. Transforming Data using MIME
  99. Enabling transformations
  100. Examples of transformations
  101. Summary
  102. 17. Supporting Features Added in MySQL 5
  103. Supporting routines—stored procedures and functions
  104. Executing code with triggers
  105. Using information_schema
  106. Partitioning
  107. Exploring the event scheduler
  108. Summary
  109. 18. Tracking Changes
  110. Prerequisites
  111. Principles
  112. Initiating tracking for one table
  113. Testing the tracking mechanism
  114. Determining tracking status
  115. Structure snapshot
  116. Exporting a version
  117. Creating a new version
  118. Deleting tracking information
  119. Summary
  120. 19. Administrating the MySQL Server
  121. Database information
  122. Server information
  123. Summary
  124. A. Troubleshooting and Support
  125. Seeking support
  126. Contributing to the project

Installing phpMyAdmin configuration storage

In addition to basic MySQL databases maintenance, phpMyAdmin offers advanced features that we will discover in the following chapters. These features require the installation of the phpMyAdmin configuration storage.

Goal of the configuration storage

The configuration storage consists of a set of tables that are used behind the scene by phpMyAdmin. They hold metadata which contains information to support special features such as query bookmarks and data transformation. Moreover, for tables using a storage engine that does not support foreign keys, relations between tables are kept in this configuration storage. The metadata is generated and maintained by phpMyAdmin on the basis of our actions from the interface.

Location of the configuration storage

There are two possible places to store these tables:

  • A user's database—to facilitate every web developer owning a database to benefit from these features.
  • A dedicated database called pmadb (phpMyAdmin database). In a multi-user installation, this database may be accessible to a number of users while keeping the metadata private.

As this storage does not exist by default and because the phpMyAdmin team wants to promote it, the interface displays the following notice message on the home page:

Location of the configuration storage

This message can be disabled with the following parameter (which, by default, is set to FALSE):

$cfg['PmaNoRelation_DisableWarning'] = TRUE;

Performing the installation

The previous error message is displayed even if only a part of the configuration storage is lacking. Of course, on a fresh installation, all parts are lacking—our database has not yet heard of phpMyAdmin and needs to be outfitted with this configuration storage. Following the here link in the previous screenshot brings up a panel explaining that the pmadb, and the tables that are supposed to be a part of it, are either missing or undefined.

It's important to realize that the configuration storage will be functional only if the following two conditions are met:

  • Proper definitions are present in config.inc.php
  • The corresponding tables (and maybe the database) are created

To create the necessary structure that matches our current version of phpMyAdmin, a command file called create_tables.sql is available in the scripts sub-directory of the phpMyAdmin installation directory. However, we should not blindly execute it before understanding the possible choices—single-user installation or multi-user installation.

Note

In subsequent chapters, we will assume that the multi-user installation has been chosen.

Installing for a single user

Even if we are entitled to only one database by the system administrator, we can still use all the advanced features of phpMyAdmin. In this setup, we will use our existing database to store the metadata tables.

We need to modify a local copy of the scripts/create_tables.sql file to populate our database with all the needed tables. They will have the prefix pma_ to make them easily recognizable. We need to remove the following lines:

CREATE DATABASE IF NOT EXISTS `phpmyadmin`
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
USE phpmyadmin;

This is done because we won't be using a phpmyadmin database but our own. Next, we should open our own database in phpMyAdmin. We are now ready to execute the script. There are two ways of doing this:

  • As we already have the script in our editor, we can just copy the lines and paste them in the query box of the SQL page. More details on this in Chapter 11.
  • Another way is to use the import technique shown in Chapter 7. We select the create_tables.sql script that we just modified.

After the creation, the navigation panel shows us the special pma_ tables along with our normal tables.

It is now time to adjust all the configuration storage related parameters in config.inc.php. This can be done easily with the setup script as seen in this chapter, or by pasting the appropriate lines from the config.sample.inc.php file. The database is our own and the table names are the ones that have just been created:

$cfg['Servers'][$i]['pmadb'] = 'mydatabase';
$cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
$cfg['Servers'][$i]['relation'] = 'pma_relation';
$cfg['Servers'][$i]['table_info'] = 'pma_table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma_column_info';
$cfg['Servers'][$i]['history'] = 'pma_history';
$cfg['Servers'][$i]['tracking'] = 'pma_tracking';
$cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';
$cfg['Servers'][$i]['userconfig'] = 'pma_userconfig';

Note

As table names are case sensitive, we must use the same names as the tables created by the installation script. We are free to change the table names (see the right-hand part of the configuration directives listed) provided we change them accordingly in the database.

The pmadb and each table have a specific function as listed next:

Function

Description

Explained in

pmadb

Defines the database where all tables are located

This chapter

bookmarktable

Contains the query bookmarks

Chapter 14

relation

Defines inter-table relations, as used in many of the phpMyAdmin's features

Chapter 10

table_info

Contains the display field

Chapter 10

table_coords and pdf_pages

Contains the metadata necessary for drawing a schema of the relations in a PDF format

Chapter 15

column_info

Used for column-commenting and MIME-based transformations

Chapter 16

history

Contains SQL query history information

Chapter 11

tracking

Contains the metadata and the actual SQL statements related to the tracked tables

Chapter 18

designer_coords

Holds the coordinates used by the Designer feature

Chapter 10

userconfig

Holds the user's preferences

Chapter 3

Between each phpMyAdmin version, the infrastructure may be enhanced—the changes are explained in Documentation.html. This is why phpMyAdmin has various checks to ascertain the structure of the tables. If we know we are using the latest structure, $cfg['Servers'][$i]['verbose_check'] can be set to FALSE to avoid checks, thereby slightly increasing phpMyAdmin's speed.

Installing for multiple users

In this setup, we will have a distinct database—pmadb—to store the metadata tables. Our control user will have specific rights to this database. Each user will work with his/her login name and password which will be used to access his/her databases. However, whenever phpMyAdmin itself accesses pmadb to obtain some metadata, it will use the control user's privileges.

Note

Setting a multi-user installation is possible only for a MySQL system administrator who has the privileges of assigning rights to another user (here, the pma user).

We first ensure that the control user pma has been created and that its definition in config.inc.php is appropriate. We then copy scripts/create_tables.sql to our local workstation and edit it. We replace the following lines:

-- GRANT SELECT, INSERT, DELETE, UPDATE ON `phpmyadmin`.* TO
-- 'pma'@localhost;

with these, removing the comment characters (double-dash):

GRANT SELECT, INSERT, DELETE, UPDATE ON `phpmyadmin`.* TO
'pma'@localhost;

We then execute this script by importing it (refer to Chapter 7). The net effect is to create the phpmyadmin database, assign proper rights to user pma, and populate the database with all the necessary tables.

The last step is to adjust all the parameters in config.inc.php that relate to relational features. Please refer to the Installing for a single user section, except for the database name in the pmadb parameter, which will be as shown in the following code snippet:

$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';

The installation is now complete. We will test the features in the coming sections and chapters. We can do a quick check by logging out of phpMyAdmin, then logging in and displaying the home page; the warning message should be gone.