If you’re using MAMP for your database driven projects you’ll probably be using phpMyAdmin to administer your MySQL database if you’ve decided to go down that route. If you’re creating a database you might be wondering how to create relationships and foriegn keys for your tables.
Firstly you need to check that you have access to the Relation view. To do this open phpMyAdmin and select a database. You need to make sure your tables’ storage engine is set to use InnoDB. Click on a table within your database and choose the Operations tab. Make sure that the storage engine is set to use InnoDB and save your changes.
Now, go back to your table view and click the Structure tab. Depending on your version of phpMyAdmin you should see a link titled Relation view below the table structure. If you can see it you’re good to go. If you can’t you’ll need to follow the steps below to set phpMyAdmin to enable Relations view.
- Find /Applications/MAMP/bin/phpMyAdmin/scripts/create_tables.sql
- I left this file default but you can change the table name to anything you want. I left mine phpMyAdmin
- Open phpMyAdmin and go to the Import tab.
- Click the browse button and find the create_tables.sql file and then click Go.
- The tables required for Relation view will be added to the database you specified.
- Open /Applications/MAMP/bin/phpMyAdmin/config.inc.php
- Find the Server(s) configuration code block and replace/uncomment the following code and fill in the values. If you left everything default in the create_tables.sql file then you should just cut and paste the lines below.
————-
$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’;
————- - Save the file and restart MAMP and refresh your phpMyAdmin console.
- Go to your database and view one of your tables in Structure mode. You should now see the Relation view link.
Excellent article, does the job, plain and simple! I needed this for a local db (demoted to using local due to myself accidentally deleting an entire db at work, whoops!)
[...] phpMyAdmin Enabling relation view [...]
hi
i am using wamp, and need to achieve the same thing please explain what you mean here at step 7:
7.Find the Server(s) configuration code block and replace/uncomment the following code and fill in the values. If you left everything default in the create_tables.sql file then you should just cut and paste the lines below.
————-
$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’;
————-
thanks
darren
Hi Darren,
You need to open the file in step 3 and search for
/**
* Server(s) configuration
*/
within the file and cut and paste the lines of text in step 7. It might be slightly different in WAMP but there should still be a config.inc.php somewhere.
Hi Darren
Iam using wamp too
please go to C:\wamp\apps\phpmyadmin3…\config.inc.phpor where the location of your wamp.
the code above exist in a file called config.sample.inc.php simply copy paste to config.inc.php and dont forget to uncomment like what KJ said
Hi Darren
Iam using wamp too
please go to C:\wamp\apps\phpmyadmin3..\config.inc.php or where the location of your wamp.
the code above exist in a file called config.sample.inc.php simply copy paste to config.inc.php and dont forget to uncomment like what KJ said
Hi, I am having trouble with this linking thing, novice to php/mysql (but understand a bit about databases) – when trying to upload the create_tables.sql file I get some errors, but I managed to upload 11 files with some troubleshooting. However now I get this error (again)
The additional features for working with linked tables have been deactivated. To find out why click here.
and it produces these errors:
$cfg['Servers'][$i]['pmadb'] … OK
$cfg['Servers'][$i]['relation'] … not OK [ Documentation ]
General relation features: Disabled
$cfg['Servers'][$i]['table_info'] … not OK [ Documentation ]
Display Features: Disabled
$cfg['Servers'][$i]['table_coords'] … not OK [ Documentation ]
$cfg['Servers'][$i]['pdf_pages'] … not OK [ Documentation ]
Creation of PDFs: Disabled
$cfg['Servers'][$i]['column_info'] … not OK [ Documentation ]
Displaying Column Comments: Disabled
Browser transformation: Disabled
$cfg['Servers'][$i]['bookmarktable'] … not OK [ Documentation ]
Bookmarked SQL query: Disabled
$cfg['Servers'][$i]['history'] … not OK [ Documentation ]
SQL history: Disabled
$cfg['Servers'][$i]['designer_coords'] … not OK [ Documentation ]
Designer: Disabled
$cfg['Servers'][$i]['tracking'] … not OK [ Documentation ]
Tracking: Disabled
Anyone know how I can fix this?