Fail to run simple SQL queries on my WordPress-database (downloading a website to a localhost)

I want to download my website to my localhost and I am having trouble running simple queries on my WordPress database so it would change all the “real” website URLs in the database to "http://localhost" (following this tutorial (second part: downloading a wordpress website without using a plugin- http://www.wpbeginner.com/wp-tutorials/how-to-move-live-wordpress-site-to-local-server/).

I downloaded all my website files from the FTP server to my localhost directory and downloaded my database (zipped).
These are the three queries that I am trying to run as mentioned in the tutorial that should change the links in my database:

Read More
UPDATE wp_options SET option_value = replace(option_value, 'http://www.example.com', 'http://localhost/Dev_site') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.example.com', 'http://localhost/Dev_site');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.example.com','http://localhost/Dev_site');

When I run these queries using PHPmyAdmin nothing happened so I decided to use MySQL Workbench.
the first query still didn’t change anything, but got this:

0 row(s) affected Rows matched: 2  Changed: 0  Warnings: 0

While I know that there it should change something in my table. I removed the last part of the query: option_name = 'home'
and got this:

0 row(s) affected Rows matched: 1  Changed: 0  Warnings: 0

One changed!!

the two other queries returned:

Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column To disable safe mode, toggle the option in Preferences -> SQL Queries and reconnect.

I tried to check/uncheck the two first check-boxes in “Preferences -> SQL Queries” as mentioned but It didn’t solve my problem.

  • Why didn’t my first query work the way it is written in the tutorial?

  • What can I do to fix the Error I got with the two other queries?

  • If it’s written in a wrong way, what is the right way to write it?

Edit:

I changed “Preferences -> SQL Queries” as mentioned before, unchecked the second box, closed ‘MySQL Workbench’ and reopened it, and got:

0 row(s) affected Rows matched: 3258  Changed: 0  Warnings: 0 

When running the second query.

Related posts

Leave a Reply

1 comment