How would you create a single database with both datasets (custom and WordPress)?

Anonymous January 25, 2014
Pinterest Stumbleupon Whatsapp

Last February you posted an article on working with custom database tables in WordPress Working With Custom Database Tables In WordPress Working With Custom Database Tables In WordPress A quick scan of the Best of WordPress Plugins page will reveal some of the many unique and niche ways you can make your blog work harder. What if you already have a database of... Read More . This is exactly the process I am looking for. I have created a database which tracks a few particulars about users and can calculate a few parameters for them based off data they provide. I want to ‘add’ this database to the WP database (or vice verse) so that I can have users log in and out via the custom database and then have access to some of the data in the tables.

If that makes sense and there is a better way to do this I am very open to change and learning (maybe its easier to have users use WordPress registration and then that grants them access to my database).

In your article, the requirements section, you mentioned that it would be required to merge an existing database into WordPress datebase or vice-versa.

I am relatively new to both WordPress and creating custom (anything) but learn quickly. I read the SSH backup article that was recommended and believe that the point of that was to show how to .TAR/.ZIP the WordPress database and then merge it with all other files on the site (including the database for the merge) using the command:

tar -vcf yourbackupfilename.tar

I don’t understand if that merges the databases though, so my question: Do you have anything copy on how to do such a merge?

If that does merge them then how do you access the table after this has happened?

Ads by Google

  1. James B
    January 25, 2014 at 10:11 pm

    That's my article, so I guess I ought to reply.

    The tar command is used to zip up a collection of files. It's unrelated to databases.

    Even if your databases were merged, WordPress can't be made to login via your custom tables, so you would need to have user accounts from WordPress then tie them to the appropriate custom tables. You can add a special field to the wordpress user profile for instance, which would act as the link to, for example, username on the other table. You can use get_user_meta() to fetch those custom fields.

    Assuming all the table names are unique, merging two databases isn't really difficult. You'll need to use PHPMyAdmin to extract data from one, then simply import it into the other. Either way is fine, just make sure your wp-config.php points to the merged database. From there, you'll be able to use that tutorial and standard wordpress functions to access your custom tables.