我想更改MySQL数据库的排序规则[重复]

This question already has an answer here:

I recently upgraded my site to PHP 5.7 and a new install of the MySQL database. The previous data was imported.

Now I have a lot of the question marks in diamonds in outputted text. I have read up, and the problem seems to be that the collation of my database is set to latin1_swedish_ci and I need to be utf8 to correctly render special characters stored in the database.

If I change the collation will this potentially solve my problem, fixing the older postings?

Do I switch off the site before changing the collation, and does it require a reboot to take effect? I'm a little nervous about corrupting the data as my users would be extremely upset to lose their historical postings.

I am not setting up a new database, I've upgraded an existing database, and need to keep the historical data.

I followed one of the answers posted below and it worked for data that was inputted into the database before the upgrade, but now renders newer data with various “ in place of apostrophes, etc.

</div>

You can use

$con = mysqli_connect("HOST","DB_USER","PASSWORD","DB_NAME");
$db->set_charset('utf8');

OR

mysql_query('SET NAMES utf8');