Replace data from command line: site name I run in mysql:

update variable set value = replace(value,'SiteName','NewName');


and then clearing cache:

drush cache-clear


But I dont know why the site name become blank instead of NewName

I've tried this after replace in variable table, but not works:

update cache set data = replace(data,'SiteName','NewName');


I hope I can change any data from command line.
The values are serialized using the built in PHP function serialize() so setting them directly shouldn't work if I understand what you did correctly. You can use drush since it appears you have that available.

Simply use:

drush variable-set site_name "Some name here"


Otherwise you can always configure from the Drupal admin interface.