Skip to main content
Home
The Baheyeldin Dynasty
The journey for wisdom starts with knowledge
  • Home
  • About
  • Site Map
  • Contact

Moving a Drupal install from a prefixed database to a non-prefixed one

  1. Home

By Khalid on 2005/10/05 - 20:14, last updated 2005/10/05 - 20:35

One of Drupal's features is that it allows database prefixes, so people can host more than one site in a single database, or share the database with other application programs.

As a site grows, people find the need to separate those sites into their own databases, making the prefix unnecessary.

To do that, the following steps are needed:

Backup the existing database

In order to start this process, you have to perform a dump of the database. This is needed for two purposes, one is to have a backup of all your data, and the second is to be able to copy it to the other database, which may be on another host altogether.

This can be done from the PHPMyAdmin web interface or mysqldump from the command line.

Load the database dump

Next, you need to load the dump you created in the new database. Again, use PHPMyAdmin or the mysql command.

Renaming the tables 

You now need to rename the tables so they do not have prefixes. In order to do that, enter the following SQL statements for each table: 

rename table pr_node to node;
rename table pr_node_access to node_access;
...

 Fixing the sequences table

The tricky part is that for some tables, there is a sequence number used to assign keys to new rows.

In order to see what the sequences are, enter the following SQL command: 

select * from sequences;

The output will be something like:

+--------------------------+-----+
| name                     | id  |
+--------------------------+-----+
| pr_users_uid             |   7 |
| pr_node_nid              | 403 |
| pr_vocabulary_vid        |   1 |
| pr_term_data_tid         |  57 |
| pr_filter_formats_format |   3 |
| pr_menu_mid              | 136 |
| banner                   |   2 |
| pr_files_fid             |   1 |
| pr_comments_cid          |   1 |
+--------------------------+-----+

As you can see most table will have prefixes in them. We need to recreate the data without prefixes.

This can be done in either one of two ways.

The first way is to delete all the data, and insert new rows without prefixes. For example: 

delete from sequences;
insert into sequences values ('users_uid', 7);
insert into sequences values ('node_nid', 403);
insert into sequences values ('vocabulary_vid', 1);
insert into sequences values ('term_data_tid', 57);
insert into sequences values ('filter_formats_format', 3);
insert into sequences values ('menu_mid', 136);
insert into sequences values ('banner', 2);
insert into sequences values ('files_fid', 1);
insert into sequences values ('comments_cid', 1);

The other way can be done via an UPDATE statement for each row. This is left as an exercise to the reader ...

Modifying the settings.php file

Now, all that remains is to modify the settings.php file to remove the prefix, and set the new database parameters. Change the $db_prefix to remove the prefix you had, and set the appropriate parameters in $db_url as needed.

Contents: 
Drupal
  • Add comment

Current

Pandemic

  • COVID-19
  • Coronavirus

Search

Site map

Contents

  • Family
    • Khalid
    • Ancestry
    • Extended
  • Friends
  • Nokat نكت
  • Writings
    • Cooking
    • Culture
    • Science
    • History
    • Linguistics
    • Media
    • Literature
    • Politics
    • Humor
    • Terrorism
    • Business
    • Philosophy
    • Religion
    • Children
  • Technology
    • Linux
    • Arabization
    • Drupal
      • Association
    • Software
    • Internet
    • Technology in Society
    • Digital Archeology
    • NCR History
    • MidEast Internet
    • Programming
    • Saudi ISPs
    • Miscellaneous
  • Places
    • Canada
      • Weather
    • Egypt
      • Cuisine
      • Alexandria
      • E.G.C.
    • USA
    • Saudi Arabia
  • Interests
    • Astronomy
    • Fishing
    • Photography
    • Snorkeling
    • Nature
    • Photomicroscopy
  • Miscellany

In Depth

  • al-Hakim bi Amr Allah: Fatimid Caliph of Egypt الحاكم بأمر الله
  • Alexandria, Egypt
  • Arabic on the Internet
  • Articles on the history of Muslims and Arabs in the Iberian Peninsula تاريخ المسلمين و العرب في الأند
  • DIY GOTO Telescope Controller With Autoguiding and Periodic Error Correction
  • E.G.C. English Girls College in Alexandria, Egypt
  • Egyptian Cuisine, Food and Recipes مأكولات مصرية
  • George Saliba: Seeking the Origins of Modern Science?
  • Internet Scams and Fraud
  • Mistaken for an Arab or Muslim: Absurdities of being a victim in the War on Terror
  • Mistaken Identity: How some people confuse my site for others
  • One People's Terrorist Is Another People's Freedom Fighter
  • Overview of Google's Technologies
  • Photomicroscopy
  • Pseudoscience: Lots of it around ...
  • Resources for using Google Adsense with Drupal
  • Rockwood Conservation Area, Southern Ontario
  • Selected Symbolic Novels And Movies
  • Snorkeling the Red Sea near Jeddah
  • Updates and Thoughts on the Egyptian Revolution of 2011

Recent Content

Most recent articles on the site.

  • Origin Of COVID-19: Natural Spillover, Lab Leak Or Biological Weapon?
  • Kamal Salibi and the "Israel from Yemen" theory
  • How To Upgrade HomeAssistant Core In A Python Venv Using uv
  • Ancestry - Paternal Side
  • Review of Wait Water Saver For Whole House Humidifiers
more

Most Comments

Most commented on articles ...

  • Another scam via Craigslist: offering more than asking price
  • Warning to female tourists thinking of marrying Egyptians
  • Craigslist classified for used car: Cheque fraud scam
  • Winning the lottery scam email: World Cup South African lottery
  • Email Scam: BMW 5 Series car and lottery winning
more

About Khalid

Various little bits of information ...

  • Khalid Baheyeldin: brief biography
  • Presentations and Talks
  • Youtube Videos
  • GitHub Projects
  • Drupal.org Profile
  • Astrophotography @ Flickr

Sponsored Links

Your Link Ad Here

Tags

Android Mobile Ubuntu Sony OnStep OpenWRT Router Ericsson COVID-19 Rogers Coronavirus Arabic Kubuntu Home Assistant GSM Telescope tablet Spectrum Scam Python 419 Laptop Firefox DIY CPU Conspiracy Comet Balkanization backup App
More

© Copyright 1999-2025 The Baheyeldin Dynasty. All rights reserved.
You can use our content under the Terms of Use.
Please read our privacy policy before you post any information on this site.
All posted articles and comments are copyright by their owner, and reflect their own views and opinions, which may not necessarily be consistent with the views and opinions of the owners of The Baheyeldin Dynasty.

Web site developed by 2bits.com Inc.