***SOLUTION***
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
from
define(‘DOMAIN_CURRENT_SITE’, ‘mydomain.com’);
to
define(‘DOMAIN_CURRENT_SITE’, ‘www.mydomain.com’);
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 https://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 “https://mydomain.com” and replace with “https://www.mydomain.com”. ***NOTE***: here make sure to put the https:// 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 https://mydomain.com to https://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 https://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 https://www.mydomain.com. So if this happens visit https://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.