I have successfully converted my multisite from non-www to www using the following method. Please be cautious and backup your db before doing it. Also read all the following instructions completely before starting the process.
1. edit wp-config.php and change
2. get the search & replace script from https://github.com/interconnectit/Search-Replace-DB and read the instructions on the site on how to use it.
It is straightforward as explained below. Put the downloaded script in your website home folder and go to http://mydomain.com/searchreplacedb21.php
step1: select the pre-populate the db values option and clik submit
step2: check your pre-populated db details and click submit
step3: select the tables (select 10 at a time: If you select all of them, the script execution time might exceed and would fail. So either select few tables at a time or increase your script execution time in your php.ini). Do not select “Leave GUID column unchanged”, so leave this unselectecd. Because this is the reason (to update GUID) we are using this script to update the db.
step4: search for “http://mydomain.com” and replace with “http://www.mydomain.com”. ***NOTE***: here make sure to put the http:// infront of your domain in your search terms, because you will have entries in the db for folders such /home/blahblah/public_html/mydomain.com and you do not want to replace these instances. So you have to search and replace for http://mydomain.com to http://www.mydomain.com
step5: The results shown on how many are replaced on the selected tables. Now use browser’s back button to go back to step3 and select the next set of tables and continue the process until you finish all the tables.
3. During the search & replace process, let us say you would start search and replace from http://mydomain.com/searchreplacedb21.php and in the middle it might say permission denied. Because for the main domain the path would have already changed to http://www.mydomain.com. So if this happens visit http://www.mydomain.com/searchreplacedb21.php and restart the process and complete the search and replace for all the tables.
4. delete the file searchreplacedb21.php from your domain.