Here I am sharing, how you can update theme from database. Step 1: Go to database and browse the "wp_options" table and try to locate "template" and "stylesheet" in "option_name" fields. You can also run below query:
SELECT * FROM wp_options WHERE option_name IN ("template","stylesheet")
see the screen shot below:
Step 2: In result you can observe the theme name is mention against each "option_name", you need to update those values with "twentyseventeen", "twentysixteen" or "twentyfifteen" to change the theme. Now from where you will get this theme names?
Step 3: Now got to folder "wp-content\themes" to see the list of themes available. It will look like below:
Step 4: Copy the folder name and update the "option_value" for "template" and "stylesheet". Make sure both values should be same. Now if you go the site theme will be updated according to new values. Wordpress version: 4.0.17