Mastering phpMyAdmin 3.3.x for Effective MySQL Management
上QQ阅读APP看书,第一时间看更新

Navigation panel

The navigation panel contains the following elements:

  • The logo (see the next section)
  • The server list ( if $cfg['LeftDisplayServers'] is set to TRUE)
  • The Home link or icon (which takes you back to the phpMyAdmin home page)
  • A Log out link or icon (if logging out is possible)
  • A link or icon leading to the Query window
  • Icons to display phpMyAdmin and MySQL documentation
  • A table name filter (under certain conditions; see later in the Table name filter section)
  • The databases and tables with statistics about the number of tables per database

If $cfg['MainPageIconic'] is set to TRUE (the default), we see the icons. However, if it's set to FALSE, we see the Home, Log out, and Query window links.

The navigation panel can be resized by clicking and moving the vertical separation line in the preferred direction to reveal more data, in case the database or table names are too long for the default navigation panel size.

We can even customize the appearance of this panel. Generally, all parameters are located in themes/themename/layout.inc.php unless stated otherwise. $cfg['LeftWidth'] contains the default width of the navigation panel in pixels. The background color is defined in $cfg['LeftBgColor'] with a default value of'#D0DCE0'. The $cfg['LeftPointerColor'] parameter, with a default value of'#CCFFCC', defines the pointer color. (The pointer appears when we are using the Full mode, which is discussed shortly.) To activate the navigation pointer for any theme being used, a master setting, $cfg['LeftPointerEnable'], exists in config.inc.php. Its default value is TRUE.

Configuring the logo

The logo display behavior is controlled by a number of parameters. First, $cfg['LeftDisplayLogo'] has to be set to TRUE, to enable any displaying of the logo. It is set to true by default. A click on this logo brings the interface to the page listed in the $cfg['LeftLogoLink'] parameter, which is usually the main phpMyAdmin page (default value main.php), but can be any URL. Finally, the $cfg['LeftLogoLinkWindow'] parameter indicates in which window the new page appears after clicking on the logo. By default, it's on the main page (value main). However, it could be on a brand new window by using the value new.

The logo image itself comes from the logo_left.png file, which is located in each specific theme's directory structure.

Database and table list

The following examples show that no database has been chosen yet:

Database and table list

It is also possible to see a No databases message instead of the list of databases. This means that our current MySQL rights do not allow us to see any existing databases.

Note

A MySQL server always has at least one database (named mysql), but in this case, we do not have the right to see it. Moreover, as of MySQL 5.0.2, a special database called information_schema appears at all times in the database list unless it's hidden via the $cfg['Servers'][$i]['only_db'] or the $cfg['Servers'][$i]['hide_db'] mechanisms. It contains a set of views describing the metadata visible for the logged-in user.

We may have the right to create one, as explained in Chapter 4,Taking First Steps.

Light mode

The navigation panel can be shown in two ways—the Light mode and the Full mode. The Light mode is used by default, as defined by a TRUE value in $cfg['LeftFrameLight']. This mode shows a drop-down list of the available databases, and only tables of the currently-chosen database are displayed. It's more efficient than Full Mode; the reason is explained in the Full mode section appearing later in this chapter. Here we have chosen the mysql database:

Light mode

Clicking on a name opens the main panel in the Database view, and clicking on a table name opens the main panel in the Table view to browse this table. (See the Main panel section of this chapter for details.)

Tree display of database names

A user, for example marc, might be allowed to work on a single database. Some system administrators offer a more flexible scheme by allowing user marc to create many databases, provided all have their names starting with marc, such as marc_airline and marc_car. In this situation, the navigation panel can be set to display a tree of these database names, such as this:

Tree display of database names

This feature is currently offered only in Light mode, and is controlled by the following parameters:

$cfg['LeftFrameDBTree'] = TRUE;
$cfg['LeftFrameDBSeparator'] = '_';

The default value of TRUE in $cfg['LeftFrameDBTree'] ensures that this feature is activated. A popular value for the separator is'_'. Should we need more than one set of characters to act as a separator, we just have to use an array such as:

$cfg['LeftFrameDBSeparator'] = array('_', '+');

Table name filter

In Light mode only, if a database is currently selected, a table name filter is displayed just under the current database name. As we enter a subset of the table names in this filter, the list of tables is reduced to match this subset. The right-hand side X control can be used to empty the filter:

Table name filter

Full mode

The previous examples were shown in Light mode, but setting the $cfg['LeftFrameLight'] parameter to FALSE produces a complete layout of our databases and tables using collapsible menus (if supported by the browser):

Full mode

The number of tables in each database is shown in brackets. The Full mode is not selected by default; it can increase network traffic and server load if our current rights give us access to a large number of databases and tables. Links must be generated in the navigation panel to enable table access and quick-browse access to every table. Also, the server has to count the number of rows for all tables.

Table short statistics

Moving the cursor over a table name displays comments about the table (if any), and the number of rows currently within it:

Table short statistics

Table quick-access icon

Starting with version 3.0, it was established that the most common action on a table is to browse it. Therefore, a click on the table name itself opens it in browse mode. The small icon beside each table name is a quick way to perform another action on each table, and by default, it brings us to the Structure view.

Table quick-access icon

The $cfg['LeftDefaultTabTable'] parameter controls this action. It has a default value of'tbl_structure.php', which is the script showing the table's structure. Other possible values for this parameter are listed in Documentation.html. If we prefer to revert to the pre-3.0 behavior, where a click on the table name opened it in the Structure page and a click on the quick-access icon led to the Browse page, we have to set the following directives:

  • $cfg['LeftDefaultTabTable'] = 'sql.php';
  • $cfg['DefaultTabTable'] = 'tbl_structure.php';

Nested display of tables within a database

MySQL's data structure is based on two levels—databases and tables. This does not allow subdivisions of tables per project, a feature often requested by MySQL users. They must rely on having multiple databases, but this is not always allowed by their provider. To help them with this regard, phpMyAdmin introduces a nested-levels feature, based on the table naming.

Let's say we have access to the db1 database, and we want to represent two projects, marketing and payroll. Using a special separator (by default a double underscore) between the project name and the table name, we create the payroll__employees and payroll__jobs tables, achieving a visually interesting effect:

Nested display of tables within a database

This feature is parameterized with $cfg['LeftFrameTableSeparator'] (set here to'__') to choose the characters that will mark each level change, and $cfg['LeftFrameTableLevel'] (set here to'1') for the number of sublevels.

Note

The nested-level feature is intended only for improving the navigation panel's look. The proper way to reference the tables in MySQL statements stays the same—for example, db1.payroll__jobs.

A click on the project name (here payroll) in the navigation panel opens this project in the main panel, showing only those tables associated with that project:

Nested display of tables within a database

Choosing from the server list

If we have to manage multiple servers from the same phpMyAdmin window and often need to switch between servers, it might prove useful to always have the list of servers in the navigation panel:

Choosing from the server list

For this, the $cfg['LeftDisplayServers'] parameter must be set to TRUE. The list of servers can have two forms: a drop-down list or links. Which form appears depends on $cfg['DisplayServersList']. By default, this parameter is set to FALSE, so we see a drop-down list of servers. Setting $cfg['DisplayServersList'] to TRUE produces a list of links to all defined servers:

Choosing from the server list

Handling many databases or tables

This section describes some techniques for coping with a server holding a huge number of databases and tables.

Limits on the interface

Before phpMyAdmin 2.11, it was difficult to work with the interface if we had access to hundreds or even thousands of databases, or hundreds of tables in the same database. Loading of the navigation panel was slow, or did not work at all. In 2.11, the interface has been reworked to take care of this.

Two new parameters, shown here with their default values, establish a limit on the number of databases and tables displayed, by adding a page selector and navigation links:

$cfg['MaxDbList'] = 100;
$cfg['MaxTableList'] = 250;

The effect of $cfg['MaxDbList'] can be seen on the main panel in Server view:

Limits on the interface

We can also see the effect in the navigation panel:

Limits on the interface

Improving fetch speed

Three configuration parameters have an effect on the speed of database name retrieval and table counting. The first one is

$cfg['Servers'][$i]['ShowDatabasesCommand'] = 'SHOW DATABASES';

Every time phpMyAdmin needs to obtain the list of databases from the server, it uses the command listed in this parameter. The default command SHOW DATABASES is fine in ordinary situations. However, on servers with many databases, speed improvements can be observed by trying other commands, such as one of these:

  • SHOW DATABASES LIKE '#user#\_%'
  • SELECT DISTINCT TABLE_SCHEMA FROM information_schema.SCHEMA_PRIVILEGES
  • SELECT SCHEMA_NAME FROM information_schema.SCHEMATA

In the first example, #user# is replaced by the current username. In extreme situations (thousands of databases), a user who installs his own copy of phpMyAdmin should put False in this parameter. This would block the fetching of any database names, and would require the population of the $cfg['Servers'][$i]['only_db'] parameter with this user's database list.

Another parameter that can help is $cfg['Servers'][$i]['CountTables'], which has a default value of True. Setting it to False would instruct phpMyAdmin to avoid counting the tables when producing the list of databases and tables in the navigation panel (in Full mode).

Finally, some users have speed issues, at least under MySQL 5.1, with information retrieval from INFORMATION_SCHEMA. The phpMyAdmin team would like to use this SQL-standard way of requesting information from the server, but the reality of its MySQL implementation leaves room for improvement. Therefore the $cfg['Servers'][$i]['DisableIS'] directive, with its default value of TRUE, disables the use of INFORMATION_SCHEMA for a major portion of the phpMyAdmin code. For your server, it may be worth setting this to FALSE to see if response time improves.