WordPress - moving from one host to another - wordpress

I am trying to move a WordPress installation from one server to another one, including all of the SQL data, and the file-system data (photos,template files).
I just have a problem changing the URLs in the database, since I need to replace the new URL with the old one.
I would love to have some suggestions about how can I replace the URLs (maybe there's a rplace statement in SQL?)
Thanks in advance.

Edit 5/16/2015
It's much better to use interconnectit.com WordPress Serialized PHP Search Replace Tool to find/replace URLs in the database and to correctly deserialize/reserialize that data. Doing a find/replace in a text dump or with the UPDATE queries below will break serialized data.
Several easy ways: How to Move WordPress Blog to New Domain or Location » My Digital Life:
UPDATE wp_options SET option_value = replace(option_value,
'http://www.old-domain.com', 'http://www.new-domain.com')
WHERE option_name = 'home' OR option_name = 'siteurl';
and others:
How to Find and Replace Text in WordPress MySQL Database using SQL When Changing Domains » My Digital Life
Search RegEx « WordPress Plugins for grepping through posts and pages as a WP plugin-based way to replace image and other URLs in posts and pages.
And there's Moving WordPress « WordPress Codex.

One thing to be aware of is that WordPress stores some of it's data using serialised arrays (some plugins in particular, such as cforms, do this).
In instances where the site URL data may be serialised, simply updating the site URL text can change the length of data in the serialised string, corrupting the data and breaking things.
Interconnectit have a php script that takes serialisation into account when doing a search replace in the WordPress database. Github repo of the script here.
I have used this script in numerous WordPress migrations and it has been a lifesaver for me.

You could simply dump the mySQL in a flat file and open it up in your favorite editor. Than do a find and replace for fully qualified domain name if you are literally change domains. That should take care of WordPress specific URL settings as well, so all your links in pages, posts, sidebars etc. will work. Also be sure to change the local path's recorded in the DB to reflect what the new ones will be as well.
Once your done import the mySQL file in to the new DB and have at it. If something when wrong in transit than you'll definitely know. :)

There is indeed a REPLACE() function in MySQL, but I would recommend doing what hsatterwhite suggests and editing the whole MySQL dump as a flat file before re-importing, not least because the REPLACE() function is case sensitive.

This is a really straight forwarded procedure with no frills but extremely detailed for newbies
Make a full wordpress backup from your local server/host using cpanel. (wp + db)
download the backup1.tar.gz generated
Install a new wp site (default theme) on the target host. Same release, please!
warning: If they are different, leverage both releases.
Make a full wordpress backup from your target host using cPanel. (wp + db)
download the backup2.tar.gz generated
Additionally backup (export) wp-admin and wp-users target mysql backups; save them for future use ahead.
enter target host cPanel > file Manager > enter wp diretory > clear all files
upload local host wp backup1.tar.gz files to target host wp directory > extract files
copy wp-config.php file from backup2.tar.gz file
paste overriding wp-config.php file on target host wp directory
enter target host > cpanel > phpmyAdmin > find mySQL BD name of your target wp host and drop all tables.
restore (import) local wp using backup1.tar.gz softsql.sql file to mySQL db on target host
drop wp-admin and wp-users tables after restore. Restore (import) wp-admin and wp-users you saved before. This will guarantee target wp authentication when entering target host wp administrative tasks.
test target host wp url
The wp-config.php copy/paste is to restore target host wp and
mySQL original authentications.
Test target wp at /wp-admin mode.
that's it! Enjoy.

I think the guy is talking about hard links in his page/ post content. You need to apply #markratledge MySQL replace function link this...
UPDATE wp_posts SET post_content = REPLACE(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');
This will replace all the links in you post/ page content...

Related

How to map or copy a wordpress site to a subfolder in an existing site's route?

I have a Wordpress blog (blog.xxx.com). I have a nuxt personal website yyy.com which is hosted on aws.
Now I wish to map or migrate the Wordpress blog (blog.xxx.com) to my personal site (yyy.com/blog).
How can we achieve this? yyy.com should show my personal site and yyy.com/blog should take you to my blog.
Can I configure this in Wordpress or what else can I do to achieve this?
I tried mapping it to a new domain, but I’m not sure how to map to a particular route and get it to work when I visit (yyy.com/blog/{blog-name}.
Yes, you can set up a WP site in a subfolder of your main website. I don't recommend doing it manually, too much can go wrong. Use a plugin such as Duplicator - it's so simple to use:
Install it on the site to copy and build a package - this packages your entire website into a single zip file
Copy this ZIP file and installer.php to the the hosting new location on your hosting (e.g. yyy.com/blog)
Create a new empty database
Run the installer wizard and make sure the URL in the new settings is https://www.yyy.com/blog
That's it!
You can have the entire site set up & running perfectly in just minutes! it will even set up .htaccess correctly.
No more setting up the database, changing urls in the database, 404 errors, broken links, broken images, etc. Moving a Wordpress site manually can be tricky and you can waste hours trying to fix the issues. Even agencies use a plugin to avoid the problems.
If I understood your question correctly, you want to move your WordPress installation from blog.xxx.com to yyy.com/blog, right?
There is an official guide for this provided by WordPress: https://wordpress.org/support/article/moving-wordpress/
After you have changed the siteurl and home fields in table wp_options of your database to yyy.com/blog, you can use a plugin like Better Search Replace (https://wordpress.org/plugins/better-search-replace/) that scans your WordPress database and replaces every URL of posts etc. with the new URL of your blog.
In addition, in case of an Apache webserver you need to take care of the .htaccess file and change the RewriteBase to /blog (assuming that it was / before).
Some special plugins (for caching etc.) need some special treatment, but often clearing the cache solves the problem.
Well despite Johannes is perfectly clear for me, i'll try to simplify.
Clone WordPress files from blog.xxx.com to yyy.com/blog directory. (not sure how your server is configured, but probably you'll be able to access it.)
Clone Database to new server.
Run sql replace queries:
UPDATE wp_options SET option_value = replace(option_value, 'https://blog.xxx.com', 'https://yyy.com/blog') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'https://blog.xxx.com','https://yyy.com/blog');
UPDATE wp_posts SET post_content = replace(post_content, 'https://blog.xxx.com', 'https://yyy.com/blog');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'https://blog.xxx.com','https://yyy.com/blog');
update your wp-config.php to match your new database.
login to yyy.com/blog/wp-admin
go to settings and update your permalinks

problem mooving woocommerce to another domain

I have a woocommerce website installed and work normally , I want to change the theme without make changes on the website so all still ( products , pages, ...etc) .
I want to copy the same website into another domain to do changes without stop my first website .
this what i have do :
1- copy all files from the old to new website.
2- import database frm the old .
3- past into the new domain all files
4- import the tables of the old database to the new database
5- change the wp-config to work with the new database
6- change the domain into table : wp_options
and i launch the new domain : the first page is ok without errors
but when i enter to preview product i have error that page dosen't exist , and all other pages the same error . can any one help me ??? any ideas ?
When moving a WordPress site a few things to make it easier.
Manually, zip up uploads/plugins/theme or if you have some crazy thing going on wp-content. Generally, nothing else needs to be moved. (this excludes things like robots.txt etc you may have to move)
After importing the DB you need to run a search and replace to swap out the domain. It is used in more places than you think.
Go to settings and re-save permalinks twice. - This fixes most issues with pages not loading/404.
There are plugins out there that make this easier.
Updraft - Don't need the paid version. Can setup new site then add files and import them.
All in One WP Migration - Haven't seen anything this doesn't move but can be slow and harder with large sites.
Plugins like All in One WP Migration or Duplicator can be helpful, but from time to time they may fail.
With AIOWM you must create a backup and a blank WP installation, install the plugin in this blank installation and import the backup. Beware that many features are paid.
With Duplicator you create a backup and an installer that you've to upload (via FTP) to the new host and there execute the installer.php script to recover the backup.
Both of them take care of the search&replace needs.
If you want to go manual, you have to copy all files via ftp, or if you've a Cpanel or similar you can upload a Zip file and then extract it via the panel (I guess you don't have the ssh access to the server).
Than you've to create a database dump via PhpMyAdmin and restore it in the new server, thank you've to change two option in the database: the site url, and the wordpress address url.
That should let you login to the website backend, but BEWARE you've to do the search and replace on your database.
To do so, easyly, you can use Better Search & Replace plugin (https://it.wordpress.org/plugins/better-search-replace/).
Guessing that http://old_domain.com is your old domain and https://new_domain.com is the new one, usually I go this way on S&R:
- Search for "old_domain.com" and replace with "new_domain.com"
- Search for "http://new_domain.com" and replace with "https://new_domain.com" if you have an active SSL certificate
Than go to Settings -> Permalink and save twice.
Everything should be fine now :)
Remember to clean every cache if you've one active.

Changed domain for Wordpress site, but no longer loading resources (trying to load resources on old domain)

I changed my domain from http://www.troov.co/blog to http://www.troov.com/blog
Despite changing the Wordpress Address URL and Site Address URL to www.troov.com/blog, it's still trying to load resources from www.troov.co, and so none of the styling or images displays correctly.
I'm guessing there is a setting somewhere which I haven't changed, but unfortunately despite trying, I can't locate it!
Thanks in advance.
You need to find/replace URLs in the rest of the database, i.e. the wp_options table as a whole, the GUIDs of posts, etc., not only for the two main site URL options you changed (Wordpress Address URL and Site Address URL).
Don't do a find/replace in a text database dump; that will break serialized data, i.e. theme options, widgets, etc. You can do a find/replace in the database with queries using phpmyadmin or adminer, but that can still break serialized data.
You must use a tool that correctly de-serializes and re-serializes php data. Use WordPress Serialized PHP Search Replace Tool. It's very popular and works well.
Also check to see that the domain is not hardcoded in wp-config.php or the theme's functions.php file in the format
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
Remove those directives, if found. See https://codex.wordpress.org/Changing_The_Site_URL
You have to change the main url from http://www.troov.co/blog to http://www.troov.com/blog in Admin Tool -> Settings -> General or directly in the wp_options table, check the option_value field for corresponding siteurl and home option_name field records.
Probably, you have your domain address hardcoded. You can check this in your theme files, how url for images are generated, etc.

Error Moving WordPress

I'm in the process of trying to move a WordPress site from "example.com/wordpress" to "newsite.com" and I've run into some considerable trouble.
I made a backup of the database and put a copy of all of the WP files onto the new host. I then tried to change the URL, but got a bunch of errors on the new page. I tried to revert back to the old site in the hopes getting everything in order again, but now everything redirects to the "new" site. My wp-config and database settings are all the same as they once were since I never deleted them off the old site. I've since deleted the files from the new site. The page is still redirecting and I can't access the dashboard login.
I'm completely at a loss right now, so I could really use some expert opinion. Thanks for any help that leads to a solution.
Old Site Link
If you have access to phpmyadmin or any interface for your database you can go into the wp_options table and update rows 1 and 36. As jogesh_pi mentioned, the base url of your site is stored there, so you will need to update the database with your new path.
You can run this query in phpmyadmin and it will do it for you. Obviously replace the newsite url with your own.
UPDATE wp_options SET option_value = 'http://www.newsite.com' WHERE option_name = 'siteurl' OR option_name = 'home'
You need to run a database query that updates all instances of your old URL with your new URL. The process is explained in detail in the Wordpress Codex.
I like to use this very useful PHP script for running the database update automatically as it takes into account serialized strings which in certain cases can break widgets or plugins if they are not addressed.
I always run into this issue, I use this plugin now to transfer wordpress sites: http://wordpress.org/plugins/duplicator/
But heres a quick fix:
Login to phpmyadmin, go to your database
Go to wp_options
Change these two options to your new url where my url's are the old ones:
If your wp-content folder is of the old site contents, it should pick up. But if your images dont show, use a URL changer plugin like this one: http://wordpress.org/plugins/velvet-blues-update-urls/
it's just a simple query that helps you to transfer your wordpress site from old to new.
update wp_options set
`option_value` = replace(`option_value`, 'example.com/wordpress', 'newsite.com');
beside this make sure about the file permissions and the database is same that you have used in the old site.

Wordpress pages won't load after hosting transfer

I've just transfered a wordpress website to another domain.
For the transfer I've made the following steps:
Copied db and changed domainnames (http://olddomain.com to http://newdomain.com)
Imported db on new host (via phpMyadmin)
Changed wp-config to match new db settings
uploaded all wp files
So the homepage works, but I can't visit the other pages. However, they are showing up in my admin page.
The way I've done this in the past and have worked for me:
1- Export db from phpMyAdmin, then replace in the .sql file all references to old domain.
2- Imported db on new host (via phpMyadmin)
3- Changed wp-config to match new db settings
4- Uploaded all wp files
5- Regenerate .htaccess file, if you are using permalinks.
(you can do this the way #Riboflavin suggests)
Also, here you can find some additional information that could help:
http://codex.wordpress.org/Changing_The_Site_URL
If you are using permalinks you will need to regenrate them after the transfer. Go to Settings → Permalinks in your admin panel and choose the permalink option you would like to use and click Save Changes. This will regenerate the permalink portion of your .htaccess file for your new domain.
Are the links to those other pages still pointing to the old domain?
If so, you could try the Velvet Blues Update URLs plugin to update all the links in your site.
I've used this successfully in the past, but recommend that you back up your data fully before trying it yourself.
The fastest transfer from my experience is through cpanel using fantastico or something that installs wordpress quickly. The process is as following:
Install wordpress on new hosting through fantastico or similar app
Delete everything in installed directory except for wp-config
Copy everything from old wordpress data, except for wp-config
Paste/transfer all that data to the new host
Now export old database and delete tables on the new one then import from old db
Change site URL within database to new one
Using fantastico helps in setting up databases quickly and wp-config. No need to do it manually and waste time. Just make sure to leave the installed one and not transfer the old one.
The whole process takes me like 2-3 minutes, I think its the fastest once you get it.
You need just to adjust your new .htaccess by regenerating it
go to WordPress dashboard
Settings > permalinks
then save modifications
if it's work then well done else you need to manually change it :
you will find the .htaccess content after saving modification in permalinks page copy the contents and create the .htaccess file in the root directory

Resources