Search code examples
drupaldrupal-7

Change prefix of tables once platform is installed


I'm working on a new website. A friend of mine configured Drupal 7 on our hosting service and we started to work. Unfortunately he forgot to add, during the setting phase, a prefix to Drupal standard tables.

Is it possible to change this configuration after having installed Drupal (in order to dont loose the work we have already done after the installation)?

I could do it via SQL code, but I guess that the platform will crash in this way because the code is generated according to the initial settings, right?

(PS: I dont have so much experience with Drupal).

Thanks!


Solution

  • I have similar issue, I found it is very easy to do this in phpmyadmin. I assume your table prefix is "drupal_", and the target prefix is "new_"

    step 1: login to phpmyadmin, chose your database;
    step 2: under table list bottom , click "check all" checkbox;
    step 3: select action "Replace table prefix";
    step 4: Type "drupal_" into "From" and "new_" to "To", click "Go"
    

    You can see the prefix was change to new_tablename enjoy : )

    oh, don't forget to change your settings.php:

    $databases['default']['default'] = array(
      'driver' => 'mysql',
      'database' => 'databasename',
      'username' => 'username',
      'password' => 'password',
      'host' => 'localhost',
      'prefix' => 'new_',  // <-- add your prefix here
    );