• [ Moderator note: moved to Fixing WordPress. Please do not use Developing With WordPress for these topics. ]

    Sorry if the question looks childish!

    I have just imported content from a site to my local version of it. The local site now runs with the content OK but i wonder where all data got stored? No database was created but I can still see the data.

    If somebody please explain the way Import works, that would be great!

Viewing 6 replies - 1 through 6 (of 6 total)
  • It has to be in the database, WordPress can’t work without database access. Log into phpMyAdmin and you’ll see it in there.

    Moderator bcworkz

    (@bcworkz)

    If you did not edit wp-config.php when you imported, your local site is working off the remote DB of the live site. This could be acceptable as long as you recognize any DB changes are reflected on the live site. You would then need to add the site domain to your hosts file so the home and site URL settings remain the live domain and links work correctly. Without this, you will keep getting bounced to the live site when following internal links. You cannot then access the live site through its domain name, you’d need to use the temporary IP URL normally used while waiting for domain registration to propagate.

    IMO you are better off with a local DB separate from the live site. There are pros and cons to each approach.

    How import works depends on what import tool you used. The wordpress-importer plugin perhaps? If you did not create a DB, the importer probably did nothing, or “imported” to the source DB.

    Thread Starter Subrata Sarkar

    (@subrataemfluence)

    First of all sorry for my beginner level knowledge. I “Exported” from live site which gave me a series of XML files. then I “Imported” them in my local site. Not using any plugin so far. I am not authorized to install a plugin on remote site.

    When I first ran the site (before importing anything), the site was blank and after importing I can see the data. For example, when I browsed Admin>Users, there was none before I imported but they appear once I did it.

    The theme I am trying to setup is a VIP theme using Chassis. After importing the XML files I logged into mysql console and show databases; command does not show me any additional database.

    There is a file called local-config-db.php which has the following content:

    
    <?php
    
    // This is generated automatically by Puppet. Edit at your own risk.
    
    define( 'DB_NAME',     'wordpress' );
    define( 'DB_USER',     'wordpress' );
    define( 'DB_PASSWORD', 'vagrantpassword' );
    define( 'DB_HOST',     'localhost' );
    
    $table_prefix = 'wp_';
    
    defined( 'ABSPATH' ) or define( 'ABSPATH', '/vagrant/wp/' );
    defined( 'WP_CONTENT_DIR' ) or define( 'WP_CONTENT_DIR', '/vagrant/wp/wp-content' );
    

    I have no idea what is happening. Please help!

    UPDATE:
    I have added a post at my local site and checked back the remote site whether it got added (in case it is really handling remote db), but its not there.

    Moderator bcworkz

    (@bcworkz)

    Ah! I see. You are correct, you have your own DB, it’s just a matter of figuring out how to access it. My previous post was based on some assumptions that turned out to be incorrect. Vagrant and Puppet are quite useful since they make setting up an environment such as yours fairly simple. They pretty much do all the setup for you. The problem is you do not have a good idea of what was done since you had no hand in it.

    I’m not familiar with your specific environment, but I can assure you that you have a mySQL DB somewhere that contains your data. I don’t know why your mySQL console doesn’t report any DBs. It may be connected to an inoperative DB server. Unless you are a really big command line fan, the console is not all that useful IMO. I think most people prefer to interact with their DB through a GUI interface, usually phpMyAdmin, which is a web app, thus accessed through your browser.

    First we should be sure the data in local-config-db.php is actually the correct data. This is not a standard WP file. The usual location for this data is wp-config.php in the WP root installation folder. Is the same data defined there? Or is local-config-db.php referenced with a require or include statement (or the *_once variants)? Whatever definitions are established in wp-config.php, whether by direct code or referenced file are what WP is using.

    Being unfamiliar with your environment, I couldn’t say if phpMyAdmin is available or how to confirm it’s existence. If there’s no phpmyadmin folder in your html (or public_html or whatever serves as the server’s public root) folder, there would be an alias setup in the Apache configuration somewhere. Assuming you access your local server as localhost, phpMyAdmin is typically accessed as localhost/phpmyadmin/ in your browser. If that’s correct, you’ll get a login screen where the username and password that WP is using will get you in.

    Once in, all DBs are listed on the left sidebar. It’s normal for there to be a few others besides the one for WP. The one you want is the one defined as DB_NAME in wp-config.php. Click on that DB. All the WP tables will be listed. If you go to the posts table, you’ll see all of your posts and much more. Never change anything through phpMyAdmin without first making a complete backup. It’s very easy to completely ruin the DB with phpMyAdmin!

    It’s a good idea to learn how to make DB backups with phpMyAdmin. Click on the WP database again, then go to the Export tab. The defaults are usually just fine. Click Go and save the file somewhere safe. There’s no particular reason right now to have a backup other than it’s always a good idea ??

    If that all worked out, you’ve identified the correct DB and you know how to directly access the data kept there. While there shouldn’t normally be a need to use phpMyAdmin at all, it can be very useful in development work or for fixing an unusual problem with WP, like resetting your password when the server’s email service does not work (common on localhost). While all this is useful information, it doesn’t answer your original question about how the import process works.

    I’m not exactly sure what Vagrant and Puppet did beyond doing for you what is normally done manually. I do know what the manual process is, that I can describe. It’s reasonable to assume the same was done via script. I’m not sure what you started with, so I’ll start at the beginning.

    The Apache server and mySQL server need to run in a Linux O/S. Since most of us do not run Linux, we setup a virtual machine that runs Linux. On this virtual machine Apache and mySQL servers are installed. The core WP files are downloaded from wordepress.org repository and placed in the desired installation folder in Apache’s server space. Typically the install.php script is run to setup WP, mainly by creating a DB and adding empty tables to it. Since we are cloning another site, this is not always necessary, depending on how the import is accomplished.

    To clone a site, all the files in the original wp-content needs to be copied to the target installation. Additionally, the DB needs to be exported. While this can be done with the .sql backup file from phpMyAdmin, WP can also export content using XML files. .sql backup files can simply be imported in phpMyAdmin. The files are a series of SQL queries that create tables as needed and populates them with data.

    With XML files, some kind of script needs to parse the files and add the data to the DB as it goes. This is commonly done with a WP plugin, but in your case Puppet handled this for you. XML files are very structured, so it’s a relatively simple script that reads each XML tag and associated data. The tags tell us exactly what sort of data is provided, so the script knows exactly what to do with each bit of data, whether it goes into the posts table, postmeta, options, or what, and in which column each bit of data is to be placed.

    Once the wp-content files are copied and the DB populated, we are not quite done. All the site links in the DB, plus the settings in the options table all point to the source site. These references need to be changed to localhost references. Whether the import script does this as it goes or after the fact matters little, as long as it is done. With manual imports, we still use some kind of script to do this, as managing serialized data cannot be handled with a normal text editor search and replace.

    Probably way more information than you anticipated! Hopefully at least some of it is useful.

    Thread Starter Subrata Sarkar

    (@subrataemfluence)

    Hi @bcworkz,

    First of all thank you so much for your continuous support and making things clearer for me.

    I would like to let you know something about my development environment;

    OS: Ubuntu 14.04
    PHP: Installed and compiled using phpbrew along with mysql and other extensions
    PhpMyAdmin: Not installed
    GUI: Sql Workbench

    Whenever I create a website using WordPress or Drupal, the default installation creates databases which I am always able to see from MySql Workbrench GUI and of course from CLI. But in this case I don’t see any database whatever way I use.

    In order to install the VIP theme I went through the following steps:

    1. Installed VirtualBox 5.1
    2. Installed Vagrant 1:1.9.4
    3. Zeroconf networking (Bonjour)
    4. Chassis
    5. VIP Plugins and Helpers
    6. VIP mu Plugins
    7. VIP theme of my client

    Then exported data from remote site (didn’t use any plugin, perhaps this is the reason I am not getting the menu to get exported although I used “All content” option – this is however a different question)

    And finally boot up my box using vagrant up, logged in to local admin and finally did an “Import”. That’s it! Site is up and running using local data.

    Next obvious thing I tried to see the database and there is none visible at least in GUI / CLI of installed MySql.

    Silly question may be, but does Vagrant and Puppet creates a new instance of database somewhere which is separate from my already installed one?

    Now the interesting part is:
    “Once the wp-content files are copied and the DB populated, we are not quite done. All the site links in the DB, plus the settings in the options table all point to the source site. These references need to be changed to localhost references” – yes, that’s the case for me too. But the question is for some links I can navigate to the pages locally but some are pointing towards the source site. Why so? Is there any possibility that the links keep me inside local environment are like “/path/to/page” and those which are pointing towards source site are actually placed like “mysite.com/path/to/page”? I assume link references are not changed / updated when Export operation generates XML files.

    I am still a newbie with WordPress and when it comes to this particular one, I am in dark! No idea where the database is, how I can access it manually and so on. I am still reading your post and trying to get the most out of it. but meantime thought it might worth if I share my environmental information.

    Thank you so much once again for what the way you are helping me continuously.

    Regards,
    Subrata

    Moderator bcworkz

    (@bcworkz)

    I’m happy to try to help, but it doesn’t always work out well. Such as in your case, I’m not familiar with your environment, so I’m making a lot of assumptions and guesses. I think the reason you are not seeing the DB in SQL Workbench is because it reflects your native Ubuntu environment. The imported site is running in a virtual box, which may be thought of as a completely different machine, it’s own O/S, Apache, DB, everything. You need to access the DB within the virtual machine. It might have phpMyAdmin even if your O/S doesn’t!

    Apparently Puppet does setup a DB server within the virtual machine. It makes sense and explains why your site works even though you cannot see the DB. Other than saying you need to access the DB from within the virtual box, I cannot advise further, sorry. phpMyAdmin has always been available to me and it just works. You may be able to use SQL Workbench by connecting to the virtual machine as though it were a remote DB server?

    About local and external links. Of course when you export the links are not fixed since export has no idea where the data is going. It’s not unusual to use export to move to a new server which will soon be pointed to by the same domain, so there is no reason to change links. WP has a native exporter, so no plugin is needed. It’s the import where a plugin or external script like Puppet is required.

    It may be that the site links that stay within your site were relative links. I advise against relative links in WP even though they may have worked in you favor this time. They frequently work against you. It may be the links were not fixed like I expected them to. It wouldn’t be too surprising, it can be a tricky process.

    Another possibility is only some links were fixed, like home and site URLs in options. Other links buried in serialized data may have been passed over. It’s possible to fix simple links in XML data prior to import by simple search and replace text editor function. The danger in doing that is it will also inappropriately change serialized data, destroying the serial structure.

    A search and replace function that is able to handle serialized data is required. I like to use the one provided by interconnect/it. It’s normally used after import but before attempting to use the site. It can be used in any WP installation at any time to search and replace anything in the DB. I’ve only used it to fix links.

    Good luck on finding that DB — there’s gotta be a way!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Where WordPress stores Imported data’ is closed to new replies.