how to delete all urls in database - mysql

I previously used an old CMS.
I moved to wordpress and I've done a lot of work, but I still have in my very old articles 1000+ internal links pointing to old urls.
I've set up redirects, but I would like to actually replace / delete the very old internal linking in the wordpress database.
I have 3 types of old linking :
/articles.php?lng=fr&pg=425 .......... so like /articles.php?stuff
/news.php?lng=fr&pg=1827 .......... so like /news.php?stuff
/2456-actualite .......... so like /id-actualite
I believe that "Search and replace" and "Better search and replace", both Wordpress plugins are only dealing with exact urls, while the ids are dynamic.
How would you delete those all links in the database, but keeping the hypertext of those links?
Thanks !

Have you tried using WP Cli?
It's a very powerful tool for this kind of problems by running some commands on your server.
Example:
# Search and replace but skip one column
$ wp search-replace 'http://example.dev' 'http://example.com' --skip-columns=guid
Have a look more on their search-replace command.

It is probably impossible to change each URL by hand.. much better way is to use something like this "https://wordpress.org/plugins/search-and-replace/" to replace all URLs you need in the database. - This does not only deal with urls but with any other text too.

Related

DNN database search and replace tool

I have a DNN (9.3.x) website with CKEditor, 2sxc etc installed.
Now old URLs need to be changed into new URLs because the domain name changed. Does anyone know a tool for searching & replacing URLs in a database of DNN?
I tried "DNN Search and Replace Tool" by Evotiva, but it goes only through native DNN database-tables, leaving 2sxc and other plugin /modules tables untouched.
Besides that, there are data in JSON-format in database-tables of 2sxc, also containing old URLs.
I'm pretty sure that the Evotiva tool can be configured to search and replace in ANY table in the DNN database.
"Easy configuration of the search targets (table/column pairs. Just point and click to add/remove items. The 'Available Targets' can be sorted, filtered, and by default all 'textual' columns of 250 characters or more are included as possible targets."
It's still a text search.
As a comment, you should be trying to use relative URLs and let DNN handle the domain name part..
I believe the Engage F3 module will search Text/HTML modules for replacement strings, but it's open-source, so you could potentially extend it to inspect additional tables.

MySQL Replace Breaks Wordpress Template

I am making a copy of a WordPress website on another server. Everything is OK in copying the database.
However, I need to replace the old domain name "old.com" with "new.com" in some MySQL tables. I am using the following query:
UPDATE wp_options SET option_value = REPLACE(option_value, 'https://old.com/', 'http://new.com/')
This works for a lot of things (like the site URL), however, it breaks all my CSS modifications to the template and all my options, it's sort of restored into default settings directly after I run the previous command.
What could be the reasons?
When moving a Wordpress table the Database Search and Replace Script by interconnect/it does the job very well.
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
The software is designed for exactly the purpose of replacing olddomain.com with newdomain.com.
All you do is extract Search Replace DB to it's own directory off the root of the Wordpress installation. You then run
newdomain.com/Search-Replace-DB-master
This will automatically find your Wordpress database and will provide search and replace field. It allows a dry run where you can check the results before doing the live run.
Hope this is useful. I have used this many times when changing the domain for a Wordpress installation and it works every time.
Never manually replace URL use https://wordpress.org/plugins/velvet-blues-update-urls/ plugin to safely search & replace old URL with new one.

Moodle - where are URLs/links stored in database?

I'm exporting an old release 1.9.2 and importing to 3.0.2.
Each module has dozens of videos that I play via an URL/link, which points to my own .PHP program on the site (and that wraps a Camtasia video).
I found that in 3.0.2, the link opens on a separate page, unless I edit each link by going to "Appearance", then "Display" and setting it to "Embed".
So I would like to write a mySQL update script to automatically set this flag for all such links (I will add a where clause to my script name).
I checked database in PHP/MyAdmin, and didn't see any likely table names.
You should attempt to use the admin tools to update everything, go to your moodle installation's main URL.
Then go to the site administration. After /admin in the url, add /tool/replace and go there.
You can there enter what you want to find in the db, and replace it with another value. Just be carefull with this tool and make a backup before you begin.

MySQL Search / Replace - Switching root domain on Wordpress Multisite

I have a Wordpress Multisite installation, and the root domain is set to root-domain.com. I would like to switch it with one of the sites of the network (site-in-network.com), and make it a root domain.
This way site-in-network.com would become the root domain, and root-domain.com would become one of the sites in the network (100+ sites).
I've done search and replace on a database before, and it worked, but I was dropping a domain all together, so I just replaced domain-a.com with domain-b.com. This time it is different, I want to keep both of them, and just switch the positions in the database.
I guess I would need to run a MySQL query. As far as I know, the root domain was set to something like "www.root-domain.com", and all other sites in the network were like "site-in-network.com" (without the .www part)
The database is about 0.5GB, so it would be good to get it right the first time.
Thank you in advance for any info.
It can be done with a search and replace, but mind you that wordpress is also storing site information in a serialized form in the tables. That means that a default search and replace will break a lot of stuff, so be careful with that.
There is however a script that takes this into account: http://interconnectit.com/products/search-and-replace-for-wordpress-databases/
Download it and put it in your root folder. (And afterwards, delete it!!)
Using this script you could change root-domain.com to root-domain.tmp.com and then site-in-network.com to root-domain.com. After that you could rename root-domain.tmp.com to site-in-network.com. Basicly what Plamen Nikolov suggested to do in the first place.
Here is a little bit of a craftily solution:
You can still workaround the situation with the find and replace technique using fake domain name:
Replace site-in-network.com with some-fake-unique-name.com
Replace root-domain.com with site-in-network.com
Finally some-fake-unique-name.com with root-domain.com.
There is also solution without changing the database, by definining HOME and SITE URL like here: Changing the Site URL

How to search a word in a html file without any java coding?

I'm doing a project in Java which creates a user manual (html files that are linked together like Windows "Help and support centre") of software. Now once a user manual is created I have only html files remaining. Now I want to search html file that contains specified keyword(Search Engine).How can I do this without Java code??
grep, find, python script, or open any file with a text editor and try edit->search
(on windows use windows search in file)
If all of your other code is written in java, then it'll be sensible (without knowing your usecase) to use java for searching as well. You might of course use some commandline programs as grep or find - or built in search functionality in a webbrowser, but if the search should be part of a java application anyway, why not go for java and e.g. Lucene?
If this 'help' is going to be online than you can embed google search in it (limiting the search results to specified site:). Alternatively if you're hosting the pages yourself you can use htdig for indexing the pages.
However if it's going to offilne you'll be better of by generating a static index page with links to topics. In order to create a more help-system-alike user experience you can hide the contents of the index in the invisible html DIV tags and add a JavaScript that takes searched phrase as an input and that unhides the matched words with their links.
Maybe I'm missing something, but have you looked at javahelp? It has indexing and searching built in, and can be used online or offline.