Use website1 users list on website2 ? Just copy the table ?

Hi,

Can you tell me if it's possible to use the same user table on 2 websites?

I would like to use a website1 users list on a website2, do I just need to copy the website1 users list table to the website2 users list database ?

Thanks a lot.

Comments

cog.rusty’s picture

In Drupal 5?

Off the top of my head, assuming that you are copying to a clean new site, the only other thing you need to do is to update the 'sequences' table by setting the 'users_uid' value to your max user ID (so that the next user who registers gets the next available ID).

If the new site has existing users, content (with authors), role assignments or profile data, things may be more complicated.

wwwoliondorcom’s picture

Yes in Drupal 5.

Thanks for reply, does it mean that I have to check which is the User ID of the latest user created and then put this number at 'users_uid' ?

Thanks again.

cog.rusty’s picture

Yes, the max user ID.

Otherwise in a new installation it will be '1' (after creating the admin account), and after importing your users, the next time that you try to subscribe another user it will try to assign '2' and you will get "duplicate primary key" errors.

That has changed in Drupal 6.

wwwoliondorcom’s picture

Importing users table works

Thank you ! I tried it and it seems ok.

wwwoliondorcom’s picture

Importing users list, changes in Drupal 6 ? Drupal 5 to Drupal 6

Hi,

Can you tell me what has changed in Drupal 6 and if there is anything else to think about when importing users list from Drupal 5 to Drupal 6 website or can I do as I did when I previously tried from Drupal 5 to Drupal 5 website ?

Thanks a lot !

cog.rusty’s picture

Drupal 6 does not have a "sequences" table, and the user ID (uid) field in the "users" table is an auto_increment field. At the end you should just check with phpmyadmin whether the auto_increment value of the "users" table is correct (the next available number).

wwwoliondorcom’s picture

Thank you so much, I will try soon.

dorien’s picture

I just exported a table from D5.

I just needed to omit the field called "timezone_country" or something, which was not present with D6.

I executed only the insert queries and made sure that the imported uid started from "after" the already present uid, so they stayed unique.
It worked, no adjustements in sequences necessary in D6.

wwwoliondorcom’s picture

How to import users from D5 to D6

Hello,

Can you tell me how to do that ?

Thanks a lot.

wwwoliondorcom’s picture

Can you tell me how to do the insert queries ?

I would like to import a drupal 5 users list to a drupal 6 website.

Thanks a lot.

wwwoliondorcom’s picture

How to set websites users as having never accessed ? How to change access column in Users table ?

Hi,

I have imported a users list on a new website but they are imported as having already accessed this new site.

How to change all the users status and set them has having never accessed this new website ?

(I need to do that to send them an automatic account reminder every 3 months)

Thanks for help.

wwwoliondorcom’s picture

Anybody's here ?

:-)

halstead’s picture

Rather then posting again in this very old thread I recommend you start a new topic and ask your question again. Update your question using all of the knowledge you have gained over the last year.

You could also read http://blog.freenode.net/2008/03/helping-others-help-you/ to help you improve your question before you submit it.

taggartj’s picture

Ok some times it is the things that sound so easy are complex !
such as when you want to have 1 drupal site and then another drupal site on same server such as a subdomain or whatever share that user table / roles or whatever here is an idea to get you started:
so you have 2 drupal installs 1 uses "LIVE_DB" the other uses "BACKUP_DB"
1) BACK UP each database then ... create a new php file and then enter:

// db conection settings 
$host = 'localhost'; 
$user = 'MYUSERINFO'; 
// should be same password for both (but have not tested) 
$pass = 'MY-AWESOME-PASSWORD'; 
$con = mysql_connect($host,$user,$pass)or die ('No connetion'); 
// select your OTHER DATABASE the one you want to copy tables to
mysql_select_db("BACKUP_DB");
// Yep drop it 
$sql = "DROP TABLE `BACKUP_DB.users`";
mysql_query($sql);
mysql_errno();
//echo "droped";
function backup_USER_table($table_name, $backup_table_name){
    mysql_query("CREATE TABLE $backup_table_name LIKE $table_name");
    mysql_query("ALTER TABLE $backup_table_name DISABLE KEYS");
	// this is the bit i could not get to work for hours untill i added the "WHERE `uid` > '0'"
    mysql_query("INSERT INTO $backup_table_name SELECT * FROM $table_name WHERE `uid` > '0'");
    mysql_query("ALTER TABLE $backup_table_name ENABLE KEYS");
}
// change this live_db and backup_db to your stuff 
$do = backup_USER_table("LIVE_DB.users","BACKUP_DB.users");

function backup_table_other($table_name, $backup_table_name){
    mysql_query("DROP TABLE $backup_table_name");
    mysql_query("CREATE TABLE $backup_table_name LIKE $table_name");
    mysql_query("ALTER TABLE $backup_table_name DISABLE KEYS");
    mysql_query("INSERT INTO $backup_table_name SELECT * FROM $table_name");
    mysql_query("ALTER TABLE $backup_table_name ENABLE KEYS");
}

$copy_user_roles = backup_table_other("LIVE_DB.users_roles","BACKUP_DB.users_roles");

echo 'Query ran';
mysql_close($con)

2) Change the connect and db info then upload that to your server then you will need to call it every time some one creates a new account
such as iframe or image include or whatever you like.

3) ! hope this helps ?