简体   繁体   中英

Import users to Mybb database from another mysql table of users

I have a website with a login/password section. it has approximatively 500 users. I've created the login and the password for all of them in a mysql table let's call it "users".

Now i've just installed a Mybb forum, which has its own mysql database (mybb_users). I dont want people to register by themeselves, i just want them to use the previous login/password they were using on my regular website.

My questions are:

1)Can i import users from a csv file in the mybb application?
2)the database structure in mybb_users is: username password salt loginkey

it is different in my "users" table which have only login and password (in cleartext)

How can i convert the password and create the login key to be usable in the mybb.

I cannot afford to create the 500 users manually.
I hope i was clear.

Thanks for your help

It is different in my "users" table which have only login and password ( in cleartext )

A solution that would work because your initial stored passwords are not encrypted at all:

Reminder of your context:

  • One custom kind of MyUserLogin table.
  • MyBB's login table. Let's called it MyBBLogin .
  • MyUserLogin 's passwords are not encrypted at all .
  • MyBBLogin 's passwords are encrypted with MD5 + Salt.

A simple solution, aside from the CSV one, would be to create this kind of php script:

  1. Select all users from MyUserLogin table.
  2. For each returned user's password ( $password_cleartext ), apply this function:

     function generate_salt() { return random_str(8); //picked from MyBB's source code } $passwordToStoreInMyBB = md5(md5($salt).md5($password_cleartext)); 
  3. Then you just have to make an insert query to populate MyBBLogin 's fields, involving the newly encrypted password ( $passwordToStoreInMyBB ) and the salt key ( $salt ).

Note that LoginKey field is just a key generated at log in time by MyBB in order to prevent some kinds of CSRF attack, especially during the logout mechanism.
You don't have to populate it yourself.
More info about the essence of this key here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM