0

Switching Wordpress databases, and I am attempting to run the Search and Replace command to change all the permalinks.

use ruepi;
update [table_name] set [field_name] =       
replace([field_name],'[http://131.193.220.64/ruepi]','[http://ruepi.uic.edu]');

I am getting back:

SQL query:

UPDATE [table_name] SET [field_name] = REPLACE( [field_name],      
'[http://131.193.220.64/ruepi]',  '[http://ruepi.uic.edu]' ) ;


MySQL said: Documentation

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your 
MySQL server version for the right syntax to use near '[table_name] set [field_name] = 
replace([field_name],'[http://131.193.220.64/rue' at line 1 

Not sure exactly where my syntax is wrong? If anyone could look over this real quick.

Edit: Still getting #1146 error, which is the same error I got when previously trying this command:

update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, 'http://131.193.220.64/ruepi', 
'http://ruepi.uic.edu/');

ERROR:

Error
SQL query:

UPDATE  `table_name` SET  `field_name` =  'http://131.193.220.64/ruepi' WHERE  
`field_name` =  'http://ruepi.uic.edu';


MySQL said: Documentation

#1146 - Table 'ruepi.table_name' doesn't exist 
julesverne
  • 109
  • 5
  • mysql uses backticks for escaping table/field names. You're using mssql `[]` – Marc B May 16 '14 at 20:00
  • You may break serialized values doing raw search/replaces. Check [search-and-replace-for-wordpress-databases](https://interconnectit.com/products/search-and-replace-for-wordpress-databases/) – brasofilo May 16 '14 at 20:11

2 Answers2

0

This does not look like a valid mysql command i.e. using [] for the column names

Should be as

update table_name
set field_name =       
replace(field_name,'http://131.193.220.64/ruepi','http://ruepi.uic.edu');
Abhik Chakraborty
  • 44,654
  • 6
  • 52
  • 63
  • I still encounter an error: #1146 - Table 'ruepi.table_name' doesn't exist An error I had while also previously using another command (updated in post) – julesverne May 16 '14 at 20:22
  • you mean you are using `table_name` I dont think you have a table called `table_name` in WP, you need to specify the table name where you need to run the command. I just added `table_name` as an example not literal – Abhik Chakraborty May 16 '14 at 20:25
  • Would this mean, I'd have to do it for every single table case? I'm looking for a command that would parse through all current table values and "search and replace" values. I did something similar for a previous website migration, but completely forgot the command used, but I believe it was something similar to the S&R function. – julesverne May 16 '14 at 20:27
  • No its not possible until you write a stored procedure to do so, In WP threre are few tables `wp_options`,`wp_postmeta` and `wp_posts` where the values needs to be changed. Check here https://wp-types.com/faq/how-do-i-migrate-a-wordpress-site-from-one-domain-to-the-other/ – Abhik Chakraborty May 16 '14 at 20:38
-1
USE ruepi;
UPDATE `table_name` set `field_name` = 'http://131.193.220.64/ruepi'
where `field_name` = 'http://ruepi.uic.edu';

Try this.

thebignoob
  • 471
  • 5
  • 11