Home » Php » How do I enable phpMyAdmin's Designer view?

How do I enable phpMyAdmin's Designer view?

Posted by: admin December 5, 2017 Leave a comment

Questions:

I am running phpMyAdmin locally and I am trying to enable the Designer tool.

Screenshot of phpMyAdmin's Designer view

How do you enable designer view for phpMyAdmin?

I have read quite a few tutorials on how to enable the Designer view for phpMyAdmin and they all have different directions that never seem to actually get it working.

I am using version 4.0.7

Answers:

The following steps will enable the Designer in phpMyAdmin 4+ assuming that phpMyAdmin is inside the folder phpMyAdmin:

  • Open phpMyAdmin/config.inc.php and phpMyAdmin/config.sample.inc.php.
  • Locate the phpMyAdmin configuration storage settings in config.sample.inc.php (lines 38-66 in 4.0.7).
  • Copy all of the control user and storage db/table config and paste it into config.inc.php. When you get done, your config.inc.php should include something like this:

4.0.7 Example:

/* change this info to whatever user has read-only access to the "mysql/user" and "mysql/db" tables */          
$cfg['Servers'][$i]['controluser']   = 'root'; //this is the default user for MAMP's mysql
$cfg['Servers'][$i]['controlpass']   = 'root'; //this is the default password for MAMP's mysql

/* this information needs to line up with the database we're about to create so don't edit it unless you plan on editing the SQL we're about to run */
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';  
$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]['table_uiprefs'] = 'pma__table_uiprefs';
$cfg['Servers'][$i]['tracking'] = 'pma__tracking';
$cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords';
$cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';

Note: We are just telling phpMyAdmin what database and table names to store specific configuration details at. Now let’s add the database.

  • phpMyAdmin installs with the SQL we need to generate the database that the Designer relies on. We just need to locate the script. In 4.0.7 the file location is phpMyAdmin/examples/create_tables.sql. Alternatively, you can copy/download this from phpMyAdmin’s github.
  • Once you locate the file, either import the file or copy/paste it into a SQL window and execute in phpMyAdmin.
  • Now, everything should be configured properly. We need to clear cookies and restart the browser.
  • When you open phpMyAdmin back up, navigate to a specific table and in the tabs you should see Designer tab.

Disclaimer: These directions are specifically based on the new folder structure in phpMyAdmin 4+. You can apply the same directions by using phpMyAdmin’s github config.sample.php and the accompanying create-table.sql. Choose your phpMyAdmin version by selecting the correct branch.

Questions:
Answers:

It can be confusing, if you just follow the other answer. Yes, you need to change the configuration as explained, but this configuration refers to a MySQL user with special privileges. This is explained here: https://wiki.phpmyadmin.net/pma/controluser under the section about pmadb features. Therefore, there are two steps: (copy-pasting from the linked page)

  1. In mysql:

    GRANT SELECT, INSERT, UPDATE, DELETE ON phpmyadmin.* TO ‘pma’@’localhost’;

  2. In ./config.inc.php:

    $cfg[‘Servers’][$i][‘controluser’] = ‘pma’;
    //Use here whatever username was created above
    $cfg[‘Servers’][$i][‘controlpass’] = ‘pmapass’;
    //use here the password to match that user

Questions:
Answers:

For Debian Jessie, 8.6 w/ phpMyAdmin 4:4.2.12-2+deb8u2 here’s how I solved this:

I know this is quite involved. Clearly there is something wrong with the installer but I don’t know where to start to get it fixed. So this is a workaround for now. There appear to be lots of people having problems with this issue, and it appears that there are a variety of solutions that work under different versions.


0) As suggested in Debian setup notes here I did this first. It didn’t fix the issue, but it may have helped. It re-asks you questions and the -p low parameter makes sure to ask all of them:

dpkg-reconfigure -plow phpmyadmin

It says “it creates a phpmyadmin database” (and it’s tables), but it does not, so we’ll create them manually below.


1) Run phpMyAdmin by entering this into your browser, (you need to have PHP enabled support in your webserver). You’ll need the username and password for your MariaDB or MySQL server. Normally the username is root. For me the server is local, so my Server Choice is localhost:

 http://localhost/phpmyadmin/

2) Unzip /usr/share/doc/phpmyadmin/examples/create_tables.sql.gz and extract the SQL. I had to use an editor to strip the comment lines starting with “–“.

(( NOTE I think this archive might be temporarily corrupt as it gives an error when I try to manually unzip it. But you can use this trick to open it:

 dd if=create_tables.sql.gz  | gunzip -f 

Also the GUI ‘Open With Archive Manager’ lets me open it.

3) Select the SQL tab, paste this sql from #2 into the SQL box, and click ‘Go’ to create the database and tables. (It’s the missing SQL that’s suppose to be in /etc/phpmyadmin/sql/create_tables.sql.)

4) Create the sql user named ‘pma’. Open phpMyAdmin, Select Home | Users | Add user, and add a new user named ‘pma’ as follows:

User name: Use text field: pma 
Host: Local: localhost 
Password: Use text field: <enter a new password for user pma>

Global privileges (leave all boxes unchecked)

5) Give the pma user full access to the new phpmyadmin data base. Again select Home | Users | Edit Privileges for the pma user. Careful now… Select “Database” toward the top of the screen. Next to ‘Add privileges on the following database:’ select phpmyadmin. Then click the ‘Check All’ box, and click ‘Go’.

NOTE: the Global privileges for pma should still be all unchecked!

6) Edit /etc/phpmyadmin/config-db.php and change the following lines:

 $dbuser='pma';
 $dbpass='<your pma user's password>';

7a) Uncomment the following lines in /etc/phpmyadmin/config.inc.php:

/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';

/* Server parameters */
if (empty($dbserver)) $dbserver = 'localhost';
$cfg['Servers'][$i]['host'] = $dbserver;

if (!empty($dbport) || $dbserver != 'localhost') {
    $cfg['Servers'][$i]['connect_type'] = 'tcp';
    $cfg['Servers'][$i]['port'] = $dbport;
}
//$cfg['Servers'][$i]['compress'] = false;

/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysqli';

/* Optional: User for advanced features */
$cfg['Servers'][$i]['controluser'] = $dbuser;
$cfg['Servers'][$i]['controlpass'] = $dbpass;

/* Optional: Advanced phpMyAdmin features */
$cfg['Servers'][$i]['pmadb'] = $dbname;
$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]['table_uiprefs'] = 'pma__table_uiprefs';
$cfg['Servers'][$i]['tracking'] = 'pma__tracking';
$cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords';
$cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
$cfg['Servers'][$i]['recent'] = 'pma__recent';
$cfg['Servers'][$i]['favorite'] = 'pma__favorite';
$cfg['Servers'][$i]['users'] = 'pma__users';
$cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
$cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
$cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';

7b) Also uncomment the following lines in /etc/phpmyadmin/config.inc.php, and change controluser to ‘pma’, and also add your password to line 3 below:

/* Optional: User for advanced features */
 $cfg['Servers'][$i]['controluser'] = 'pma';
 $cfg['Servers'][$i]['controlpass'] = '<insert your password here>';

/* Storage database and tables */
 $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
 $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]['table_uiprefs'] = 'pma__table_uiprefs';
 $cfg['Servers'][$i]['tracking'] = 'pma__tracking';
 $cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords';
 $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
 $cfg['Servers'][$i]['recent'] = 'pma__recent';
 $cfg['Servers'][$i]['favorite'] = 'pma__favorite';
 $cfg['Servers'][$i]['users'] = 'pma__users';
 $cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
 $cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
 $cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';

8) Then logout/login.


Note, on Debian the important directories are:

  • /etc/phpmyadmin/ – your editable setup files
  • /usr/share/phpmyadmin/libraries – includes a default setup file
Questions:
Answers:

For me on MySQL 4.6.0 the Designer view was accessible but would not save the layout state.

I then did the following to make it work:

  1. created a ./phpmyadmin/config/ directory
  2. chmod 777 config
  3. went to http://localhost/phpmyadmin/setup/ and followed basic instruction, using defaults
  4. then in the phpmyadmin web app there was a red hyperlink in a footer bubble that said something about a table needing to be created (I don’t remember the exact text or which navigation section I was in… my guess was on a database in the operations tab). This created a new table called phpmyadmin and I think it’s where the designer saves layouts to.

After doing this I was able to save the state of my designer layout – i.e. phpMyAdmin Designer was now enabled.

Leave a Reply

Your email address will not be published. Required fields are marked *