Complete guide to migrating existing users to your subdomain login system with separate databases.
This guide covers how to migrate existing WordPress users from your main site to your subdomain when both sites use separate databases.
| Method | Best For | Difficulty | Time |
|---|---|---|---|
| SQL Direct Export/Import | 100+ users, preserves passwords | Medium | 15-30 minutes |
| CSV Export/Import | <100 users, manual review needed | Easy | 30-60 minutes |
| Custom PHP Script | Complex requirements, custom logic | Advanced | 1-2 hours |
Recommended for 100+ users. Preserves password hashes and user metadata.
-- Export users (replace wp_ with your prefix)
SELECT * FROM wp_users
WHERE ID > 1 -- Exclude admin if needed
INTO OUTFILE '/tmp/users_export.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
Use the provided PHP migration script (available in downloads section below).
-- Check user counts match
SELECT COUNT(*) FROM wp_users;
-- Verify specific user exists
SELECT user_login, user_email FROM wp_users WHERE user_login = 'john';
Best for smaller sites (<100 users) or when you need to review data before import.
During migration, copy the user_pass field from the main site to the subdomain. This preserves existing passwords without requiring users to reset them.
-- Copy password hash for specific user
UPDATE subdomain_wp_users
SET user_pass = (
SELECT user_pass FROM main_wp_users
WHERE user_login = 'john'
)
WHERE user_login = 'john';
If you can't copy password hashes, require users to reset passwords on first login.
For ongoing password sync, consider implementing a custom solution using WordPress hooks to sync password changes between sites via REST API.
-- Count users on main site
SELECT COUNT(*) as main_site_users FROM main_wp_users;
-- Count users on subdomain
SELECT COUNT(*) as subdomain_users FROM subdomain_wp_users;
-- Find users that exist on main but not subdomain
SELECT user_login FROM main_wp_users
WHERE user_login NOT IN (SELECT user_login FROM subdomain_wp_users);
Contact our support team for assistance with your user migration.
Contact Support