Can I convert MySQL database character set from latin1 to utf8 without losing data?
<p>I want to convert my database to store unicode symbols.</p>
<p>Currently the tables have:</p>
<p><strong><code>latin_swedish_ci</code></strong> collation and <strong><code>latin1</code></strong> character set</p>
<p>OR</p>
<p><strong><code>utf8_general_ci</code></strong> collation and <strong><code>utf8</code></strong> character set</p>
<p>I am not sure how the existing data is encoded, but I suppose it is <strong><code>utf-8</code></strong> encoded, as I am using Django which I think encodes the data in <strong><code>utf-8</code></strong> before sending to the database.</p>
<p>My question is:
Can I convert the tables to <strong><code>utf8_unicode_ci</code></strong> collation and <strong><code>utf-8</code></strong> character set using the following queries without messing up the existing data? (as sugested in <a href="https://stackoverflow.com/questions/6115612/how-to-convert-an-entire-mysql-database-characterset-and-collation-to-utf-8?lq=1">this</a> post)</p>
<p><code>ALTER DATABASE databasename CHARACTER SET utf8 COLLATE utf8_unicode_ci;</code></p>
<p><code>ALTER TABLE tablename CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;</code></p>
<p><em>Considering latin1 is subset of utf-8, I think it sould work. What do you guys think?</em></p>
<p>Thank you in advance.</p>
<p>P.S: The version of MySQL is: 5.1</p>