I am moving a website from shared hosting to a VPS but I am unable to import the database correctly as I am getting a 500 error on my website. I will list the steps I have taken below, please could you check that I am not missing anything, thanks.
I set up the VPS on Digital Ocean with the one click WordPress install and I set up the WordPress install etc.
Uploaded the theme and plugins to the correct folders on the sftp.
Created a new database on the VPS using Sequel Pro and then imported the old database to it.
Accessed the new database through mysql on the terminal and ran the following commands;
UPDATE sw13_options SET option_value = replace(option_value, 'https://olddomain.co.uk', 'http://newdomainIP') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE sw13_posts SET guid = replace(guid, 'https://olddomain.co.uk','http://newdomainIP');
UPDATE sw13_posts SET post_content = replace(post_content, 'https://olddomain.co.uk', 'http://newdomainIP');
UPDATE sw13_postmeta SET meta_value = replace(meta_value,'https://olddomain.co.uk','http://newdomainIP');
UPDATE sw13_options SET option_value = replace(option_value, 'https://olddomain.co.uk', 'http://newdomainIP') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE sw13_posts SET guid = replace(guid, 'https://olddomain.co.uk','http://newdomainIP');
UPDATE sw13_posts SET post_content = replace(post_content, 'https://olddomain.co.uk', 'http://newdomainIP');
UPDATE sw13_postmeta SET meta_value = replace(meta_value,'https://olddomain.co.uk','http://newdomainIP');
Opened the config.php file and updated the database name to the new one and changed the table prefix to sw13_ and defined the site url.
Have I made a mistake or have I not done something?
Related
I use this commands to migrate in the old day, but with divi or elementor, some crash with migration, anyone use other way ? other idea ? It's due to Json ?
UPDATE wp_options
SET option_value = replace(option_value, 'http://www.old-site.com', 'https://www.new-site.com')
WHERE option_name = 'home'
OR option_name = 'siteurl';
UPDATE wp_posts
SET guid = REPLACE (guid, 'http://www.old-site.com', 'https://www.new-site');
UPDATE wp_posts
SET post_content = REPLACE (post_content, 'https://www.old-site.com', 'https://www.new-site.com');
UPDATE wp_postmeta
SET meta_value = REPLACE (meta_value, 'http://www.old-site.com','https://www.new-site.com');
Thanks
You shouldn't change the guid as that will cause RSS readers to think that all of the posts are now new unread posts.
You might be missing some stuff to replace. Typically when migrating to the new site you do the find and replace on everything in the database (except for the guid). There are some tools that can help you out with this. If you use wp-cli, you can use the wp search-replace command. Otherwise, this is a great tool. Both of these tools will automatically handle doing a proper search and replace inside of any serialized strings.
Also remember to clear out your cache.
I am not a huge expert in MYSQL nor Regex (I guess I need to use some here), I would appreciate any help.
So my problem is that I would like to change some hardcoded URLs in Wordpress post contents to different ones.
Here is an example of a URL:
http://cdn1.domain.com/wp-content/uploads/2017/05/16211742/Screenshot_051117_101304_AM.jpg
Now, 'cdn1' can be cdn, cdn1 or cdn2. We might need to run 3 queries, but that is not a problem.
I would like to change all instances of this to:
//domain.com/wp-content/uploads/2017/05/16211742/Screenshot_051117_101304_AM.jpg
So basically remove the cdn (cdn, cdn1, cdn2) part, and remove the timestamp URL part before the filename.
The Wordpress database is something like this:
UPDATE wp_posts
SET post_content =
WHERE
Thank you very much!
First of all, take a database Backup for safety.
Then you can do this with SQL Command like this
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
OR you can do this with the plugin called: WP Migrate DB
There has a tutorial on the plugin page. check that.
Hope it will help you. :)
This line of code says that it works (green check) but I don't see an image inserted. The file path should be correct because I got it from the file data.
UPDATE `inventory`
SET bookImage = LOAD_FILE('C:\xampp\htdocs\1059\homework\books\wuthering.jpg')
WHERE isbn = '978-0141040356';
one thing u should have know that if you're connecting to a remote database server, the path is relative to the server that the DB is on, not your local machine.
UPDATE inventory
SET bookImage =
(SELECT BulkColumn FROM OPENROWSET(BULK N'C:\wuthering.jpg', SINGLE_BLOB) AS x)
WHERE isbn = '978-0141040356';
I transfer WordPress website from localhost to live but there some url and images url not changes, how can change URL permalink in WordPress database by sql query or any other method.
I use below sql query but anythings not happen please help me...
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';
Thanks in advance
Here is a link to an article from the official wordpress.org page, it covers most of the url changing topic.
It shows the several diverent ways how to do it and also the sql way via phpmyadmin. The raw sql is not shown, but there are several methodes.
In this Blog post a very simple way is described.
I copied the relevant sql statments from the blog post:
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
This should change the Url's easy
I'm working on a migrated WordPress, site url changed, everything works fine except some serialized data stored by a plugin.
The data is stored in the wp_options table, in the option_value column, for each record that the plugin saved.
So the data is still there, the problem is that when the url changed, it didnt get re-serialized (the count of the string content still thinks it's the old url lenght), therefore the plugin isn't working properly.
So, to find exactly the records that need to be updated, I use
$t1 = $wpdb->prefix . "vslider";
$t2 = $wpdb->prefix . "options";
$records_ineed = $wpdb->get_results("SELECT * FROM '".$t1."', '".$t2."' WHERE '".$t1."'.option_name='".$t2."'.option_name");
That gives me exactly the records that I need to re-serialize (it matches the name of the record created in the plugin table, with the record created in the wp_option table)
What do I do now?!
How do I take only the option_value of each, unserialize it, reserialize it and update the existing value in the db?
Should I save the reserialized values to a new table, and then replace from that table back to wp_options? How?
Otherwise what are other solutions?
There is no need to do that , what you need is to import the value as - is . it is an array and it will work fine as such as long as you do not alter the data in any way.
At any event , when you import migrate a wp site to another URL , there is absolutely no need to read the wp-options tableĀ“s columns one-by-one .
What you need to do it just dump your SQL from the Original ( old-domain ) site , then import into the new-domain , and then run these queries :
/**
To update WordPress options with the new blog location, use the following SQL command:
**/
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';
/**
After that you will need to fix URLs of the WordPress posts and pages, which translated from post slug, and stored in database wp_posts table as guid field. The URL values in this field are stored as abolute URLs instead of relative URLs, so it needs to be changed with the following SQL query:
**/
UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com','http://www.new-domain.com');
/**
If you have linked internally within blog posts or pages with absolute URLs, these links will point to wrong locations after you move the blog location. Use the following SQL commands to fix all internal links to own blog in all WordPress posts and pages:
**/
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');
Just for verification , after running those commands , go back to the options table and verify that your home and site_url functions are both correct as for the new-domain data.
If you do still want , for some obscure reason, insert data directly into the options table manually ( ?? why ) then you should consider using get_post_meta() and update_post_meta() function which will take care of the serialization.