Hi,

I'm trying to migrate to Drupal and I'm having too much trouble trying to set the prefix on all the Drupal's tables. In the settings.php I wrote:

$db_prefix = 'drupal_';

then I upload it to the sites/default folder.

In the SQL tab of my database in the MyPhpAdmin I upload the local copy of the database.4.1.mysql file.
Note: I haven't been able to include the remote file.

altough I had changed the $db_prefix the tables do not have any prefix at all.

does anybody knows what's happening?

cheers,
Felipe.

Comments

pwolanin’s picture

For 4.7 you have to prefix the tablenames in the SQL file manually, or use the supplied shell script. This has to be done before loading them in to the DB.

---
Work: BioRAFT

felipebm’s picture

For 4.7 you have to prefix the tablenames in the SQL file manually...

how can I do this?

thanks for your help,
Felipe.

vm’s picture

open the mysql file that you are going to use in an editor.

every "CREATE TABLE" and "INSERT INTO" needs to be prefixed.

example:

--
-- Table structure for table 'access'
--
CREATE TABLE access (
  aid tinyint(10) NOT NULL auto_increment,
  mask varchar(255) NOT NULL default '',
  type varchar(255) NOT NULL default '',
  status tinyint(2) NOT NULL default '0',
  PRIMARY KEY (aid)
)
DEFAULT CHARACTER SET utf8;

The above needs to be changed to

--
-- Table structure for table 'access'
--
CREATE TABLE prefix_access (
  aid tinyint(10) NOT NULL auto_increment,
  mask varchar(255) NOT NULL default '',
  type varchar(255) NOT NULL default '',
  status tinyint(2) NOT NULL default '0',
  PRIMARY KEY (aid)
)
DEFAULT CHARACTER SET utf8;

note the word prefix_ in the above example. you would have to do this for each table that is to be created prior to importing the db tables. obvioulsy "prefix_" is a place holder for the prefix that you are going to use in settings.php.

so if your prefix is drupal_ then the table to create needs to reflect this.

--
-- Table structure for table 'access'
--
CREATE TABLE drupal_access (
  aid tinyint(10) NOT NULL auto_increment,
  mask varchar(255) NOT NULL default '',
  type varchar(255) NOT NULL default '',
  status tinyint(2) NOT NULL default '0',
  PRIMARY KEY (aid)
)
DEFAULT CHARACTER SET utf8;

next an example of the insert

example:

INSERT INTO system (filename, name, type, description, status, throttle, bootstrap, schema_version) VALUES ('modules/block.module', 'block', 'module', '', 1, 0, 0, 0);

needs to also have your prefix added to it. therefore it needs to read this way before importing in to database.

INSERT INTO drupal_system (filename, name, type, description, status, throttle, bootstrap, schema_version) VALUES ('modules/block.module', 'block', 'module', '', 1, 0, 0, 0);

again, the above example, is assuming, drupal_ is your prefix.

felipebm’s picture

you also have to edit every "INSERT INTO " command, as an example:

INSERT INTO system

change it for:

INSERT INTO prefix_system

thanks a lot buddy!!

vm’s picture

that is also stated in my post at the end. you may have read it before i was finished with the final editing.

no worries, glad you got it sorted.

nagaral’s picture

I have installed drupal on my local machine say http://otg.com:9090 and created a sub domain http://org.otg.com the sub domain has its own $db_prefix(say "org_") but is pointing to the same database instance of main domain.The main domain doesn't have any prefix.Now the problem is when i type http://otg.org.com a new drupal site will open and i have created a new account say "test"/"test".Now my subdomain is ready for customization.But when i logout and login it is simply showing the same page and is not accepting my login information.Could any body Pls help me in this issue.

I am using

PHP 5.0
Apache 2.x
Drupal 4.7

Regards,

Nagarajan.L

Anatsim’s picture