Several people have had success dumping a copy of the database in a text file, using their favorite editor (beware this could be a really big file) to search and replace, and then restore the modified dump back into the database.
Of course, you need to be sure noone is using Moodle while you do all the search, replace & restore. Otherwise you'll loose all the new content.
I'd do it in a test server first (even several times) to get a grip on it before even trying on the production server.
Saludos. Iñaki.

If you dont have time to explain, just lead me to somewhere i can get clear info about the issue.
thank you lots!
You edit that file and then restore (using mysql command line client, for example) your modified database back.
Simple yet effective.
Saludos. Iñaki.
Hello
I am using moodle 2.2 on arvixe hosting company with cpanel
I bought a new domain name and so I am using the same name server.
My question:
do I have to follow the below bold directions even if I am using the new URL on the same hosting company and same server?
my question comes from confusion regarding the following section of docs.moodle:
(http://docs.moodle.org/22/en/Moodle_migration)
Change your Moodle URL. If you have a new URL, you'll need to change this in the Moodle database to the new server. This is needed as links to pictures, files, etc are stored as absolute links and will reference the old $CFG->wwwroot value. So when loading a mysql backup dump of the Moodle server into mysql on another server the absolute referenced links will be broken. There are two methods of doing this:
(a) The first method changes the Moodle URL using the Moodle script replace.php while your site is currently running just before you backup the Moodle database. Point your browser to http://yourserver.com/admin/replace.php
Enter the url for your old server (http://oldserver.com/) and new server (http://newserver.com/) and it will fix the mysql tables.
Do I need to do this even if I am on the same server? Because I am chaning url from
http://supremeducation.com/studyonline/
to
If so how?
Sincerely,
Dominick Inglese
I am on Moodle 2.2.2+ (Build: 20120419) and have a DNS entry so it points to http://moodle.myintranetserver.org instead of using the server's hostname. I dumped the moodle database but can't find any entry that points to the host name or ip address to replace to the DNS alias.
I get the following message: "Incorrect access detected, this server may be accessed only through "http://myServerHostName" address, sorry.
Please notify server administrator.
This page should automatically redirect. If nothing is happening please use the continue link below.
Continue"
Amer
I use PHPMyAdmin to edit the database directly calling a file with a number of SQL update commands of the form:
update mdl_resource
set alltext=(
replace(alltext,
'http://oldname.com',
'http://newname.com'));
I have attached a file with the full set I use. This may not adjust all the tables you have references in and I know it does not address the problem with links or images in labels.
WARNING try this on a test server first and make a backup of your database in case.
Regards
Steve
Amer
I have used Iñaki's solution but my database is very large and the mysql dump was therefore a large file which took a long while to process in my text editor before reading back in.
My sql script runs in less than a second in place and as I use this at least once a day when I restore a backup of my live site into my development site this is a great advantage.
If you do find any broken links they can always be edited manually which is what I do with the link in a label which I have not managed to sort out any other way!
Regards
Steve
Amer
On a one off basis you are probably better off using Iñaki's solution as if it takes a long time then this will only be the once.
I think my script gets every occurrence except labels and I was only suggesting manual editing for any which were missed as they were reported to you.
Regards
Steve
For those Unix/Linux admins out there, using 'sed' to process the database dump makes the search & replace operation blazingly fast
If you've got a sed that's option compatible with GNU sed, you can even use the '-i' option to process the file in place, which avoids using temporary files for the operation (saving a few more seconds).
Saludos. Iñaki.
Does anone know a way of doing this more globally? Following will not work of course, but...along these lines and only at night
Update * SET (*)=replace(\1,
'http://oldname.com',
'http://newname.com'));
Timothy
hi Martin,
i just want to know that how reliable is "replace.php" we have more tahn one servers and we are frequently taking backup from one server and restorinf them on the other servers so we have to replace the links with new ones. so i am thinking of putting this script in the end of restoration so that it will automatically run on every restoration ?????
Some courses if not most, have pictures in the title of every topic in the course. I am testing the replace function coz i need to change the site address. The pictures are still pointing to the old site name even after i used the replace method.
Are there any tables/columns which this function skips? What do i need to edit in this function?
thank you,
amer
Check this link out http://moodle.org/mod/forum/discuss.php?d=62959
I did this on the weekend twice and it worked a treat.
Oddly some of the urls didn't completely change until I had flushed the cache which can be done by logging into the site and editing a section with the old url and then exiting edit mode.
About 15 minutes from start to finish without issue.
hello ~
I tried to type this into my url address but I got a 404 error.
moodle is installed in this directory:
http://supremeducation.com/studyonline/
so I would enter the following:
http://supremeducation.com/studyonline/admin/replace.php
but I get a 404 error
can you advise me on this please?
Sincerely,
Dominick Inglese