D Rice D Rice - 9 months ago 31
PHP Question

I Want to Change the Collation on my MySQL Database

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.


You can use

$con = mysqli_connect("HOST","DB_USER","PASSWORD","DB_NAME");


mysql_query('SET NAMES utf8');