WordPress.org

Ready to get started?Download WordPress

Forums

Why is URL stored in database? (17 posts)

  1. bwooster47
    Member
    Posted 8 years ago #

    I just moved from one domain to another, and this process involves hand editing the MySQL Dump file, and replacing old-domain to new-domain.

    This process seems very delicate, I found so many instances where the old-domain was mentioned in the sql dump, and I was not sure if I should be changing all instances - it is fine to have the old-domain mentioned in the blog post, etc.

    Was just curious why the Famous 5 Minute Install package should make it so cumbersome to move from one folder to another, or to move from one domain to another - I did the same thing with Drupal, that was a breeze! Just change the config PHP file, and restore old DB, and it is done.

    Is this something that is just there for historical reasons? Any chance of this feature being added in some future release - basically, keep all URL/folder definitions in a .php file and not in the database...

  2. Mark (podz)
    Support Maven
    Posted 8 years ago #

    There is a guide here (on the right) http://www.tamba2.org.uk/wordpress/ which helps.

  3. James
    Happiness Engineer
    Posted 8 years ago #

    Actually, if you would have followed the proper instructions, you would have never had to touch the database.

    The site_url and home values in the database are vital to a few of WordPress' core features and several plugins. Though they are stored in the database, they can easily be edited in Options/General before moving the blog.

  4. Beel
    Member
    Posted 8 years ago #

    Are there lots of site links? I did a search of my database and beyond a few options which require the blog link (upload directory, etc.) the rest are all links I added in posts.

  5. bwooster47
    Member
    Posted 8 years ago #

    Reply to "Posted: 2005-10-16 20:39:09"
    To the person who said to "follow the proper instructions" and don't touch the db - please read your link to instructions again! Here's what they say:

    Make a copy of your database. You will need to edit the .sql file, and in case of errors, it is important that you work on a copy.

    And it explains how to edit the .sql file... do a web search for WordPress and moving and domain - you will see people even talking about using the right editor that can handle the long lines in the .sql file!

    So, a lot of people are having to jump through hoops to do this..

  6. bwooster47
    Member
    Posted 8 years ago #

    Reply to: Posted: 2005-10-16 20:41:51
    > Are there lots of site links?

    Yes, when I edited the SQL file, I had to do a mass-replace, it ended up replacing 65 instances.

    Most were in this SQL line:
    INSERT INTO ac1_posts VALUES ...
    for example:
    ..body of post.....','title of post',0,'','publish','open','','','tile of post',''
    ,'','2003-03-02 14:29:39','2003-03-02 18:29:39','',0,'URL-old-domain/weblog/?p=2',0),...

    There are so many lines with that format:
    URL-old-domain/weblog/?p=<some number>

    Based on all the instructions (including the links mentioned in replies to this thread), I replaced all URL-old-domain to URL-new-domain - was that not necessary?

    If it matters - originally this was a Movable Type blog. I moved that to WordPress on URL-Old-Domain. Then after some time, I had to move to URL-New-Domain...

  7. bwooster47
    Member
    Posted 8 years ago #

    One more addendum - the instructions for moving say that <b>before</b> you move, you have to change the Options in wordpress.

    This is impossible in some cases - when you don't have access to the old address, only have a backup to restore to a new address.

    In that case there is no way to operate any WordPress function, can't even login.

  8. vkaryl
    Member
    Posted 8 years ago #

    Um. I've moved my 8 blogs a number of times from host to host, and in a couple of cases, not only to a new host but to a new domain at the same time. All I've EVER done is edit the config file and the Options/General page (as macmanx stated).

    They're working just fine.... I'm not sure why you've had such a time with it.

  9. Mark (podz)
    Support Maven
    Posted 8 years ago #

    I've moved dozens too, and my guide has been used many many times. It's hardly brain surgery to make a few changes is it ?

  10. Beel
    Member
    Posted 8 years ago #

    Options:
    site url
    upload url
    home url
    rss links (a bunch cached but not relevant)
    couple of plugin cache paths

    The first three are the only ones I could find in my sql that are absolutely necessary and don't know how to avoid 'em. I am not saying you are wrong, not by any means, I am just saying I don't see a whole lot of links other than the ones I added in posts.

  11. James
    Happiness Engineer
    Posted 8 years ago #

    Actually, the upload url and rss links are all relevant to the site url and will adjust accordingly. Most the plugin cache paths will do the same. If they do not, then the plugin should be updated to take advantage of the site url.

  12. Beel
    Member
    Posted 8 years ago #

    For awhile I was creating blogs and testing/tweaking them off my computer and then uploading them to other servers. I just don't remember it being difficult atoll.

  13. bwooster47
    Member
    Posted 8 years ago #

    Thanks for all the replies, I guess if only I had changed the settings before I moved (that is like giving directions by telling someone to watch them get off the bus, and then get off one stop before they do :-) )

    I understand that if you do things before you move, maybe you don't need to edit the SQL (if you know the name of the new place before your old place is locked out, etc).

    So, all I'll suggest is this - if at all possible, I would like to propose a feature enhancement: follow the example in Drupal - always use folder names and URL options from a .php file and not use values stored in a database.
    Far more people find it easy to edit .php files, and are lost editing/navigating a database.

  14. vkaryl
    Member
    Posted 8 years ago #

    But you don't edit the database. I CAN tweak a database, but I haven't once had to. I've only edited the config file which IS .php, and a couple of fields in the Options section.

    Actually, I personally find Drupal a PITA to move and deal with. I've done that too, m'friend, as well as mambo/joomla, phpLD, phpBB, etomite, phpWebsite, cubecart, and 20 or 30 other php apps - NONE of which was basically as simple to deal with as WP.

    YMMV, of course.

  15. bwooster47
    Member
    Posted 8 years ago #

    vkaryl - you may be right, but I can't test what happened again easily (would need to move to another domain).

    In which case - I would like to suggest some changes to the docs - they seem to suggest that editing the SQL is necessary, or the docs insist on doing things before, not after the move.
    You seem to suggest is that moving is simply this:
    1) restore db
    2) edit wp-config.php (if needed - only needed if db user name or db name was changed)
    3) login as admin - assuming that while wordpress pages won't work (pointing to old domain), you can still go to the Options pane, and enter new URL and folders, and then wordpress pages will also work ok.

    Is that right? Here are phrases in the http://codex.wordpress.org/Moving_WordPress that threw me off, and I ended up thinking I needed to edit SQL, and so went that way:

    Moving WordPress Within Your Site
    It is important that you set the URI locations BEFORE you move the files.

    -->implication: don't do this before you move, and then you are hosed!

    Another section:

    Moving WordPress to a New Server
    ....
    You will need to edit the .sql file, (this is in bold)

    Based on what you said, that is not really true - you only need to edit the SQL if you want to edit each post, and change the URLs/email addresses inside the posts - nothing in WordPress needs you to edit the SQL.

  16. vkaryl
    Member
    Posted 8 years ago #

    My own experience is that you never need to edit the database UNLESS you have done a lot of custom tweaks. I started blind with WP in February, and made my first host/domain move in March. Absolutely all I did (and I didn't even know about codex at the time!) was copy the entire WP folder, create a database on the new domain, dump the original database to file, change the config file to match the info for the new database and host, and access the new db in phpMyAdmin, do a query to grab the info from the dump.

    I *think* (long time back now) that I got some errors, went back to the original setup on the old host, changed the URLs in the Options section, then reuploaded stuff and it was fine. I won't swear to that, but since then, I've changed the URLs FIRST, then copied, dumped, uploaded, queried, etc. and it's worked first time every time.

    I point out as a caveat however that I am the only person in the world who NEVER has bugs in games (such as Daggerfall, BG 1 and 2, NWN, etc.) so you REALLY need to believe that YMMV.

  17. davidchait
    Member
    Posted 8 years ago #

    actually, just to interrupt quickly, only the site url and home url are likely required to get the site 'basic' functionality back up and running. Doing a big search and replace is a problem, as there are cases where you are changing things like GUIDs for permalinks that should still note the ORIGINAL URL of the post (and NOT the new domain). Of course, if you embed absolute-URLs inside your posts, well, then you are in trouble... that's why I came up with some quick tags (part of my CG-Inline plugin) that let me refer to other numbered posts on my site just by referencing the post number (thus not embedding a URL at all).

    Yes, it'd be nice if there was a script you could run to update the appropriate URLs in the DB when moved -- but I'm also trying to recall if you can log-in to wp-admin for a site post-move, pre-changes... I would think/hope you could, but maybe not. :(

    -d

Topic Closed

This topic has been closed to new replies.

About this Topic