Hi guys is there a safe way to convert a table from latin1_swedish to fully utf8?
Someone can explain me which are the steps to safely do it?
(maybe using phpmyadmin dunno)
Hi guys is there a safe way to convert a table from latin1_swedish to fully utf8?
Someone can explain me which are the steps to safely do it?
(maybe using phpmyadmin dunno)
charset
and collation
as needed.I am not sure of any specific pitfalls in changing to/from utf8, but the backup should serve you well should anything go wrong.
I assume latin1_swedish_ci is default collation of your database server. In such case i use the following collations:
There can be number of solutions to this problem, but the following solution worked for me in some worst case scenarios too.
Steps:
Fill the new table with data in old table, using CONVERT.
--Copy table structure
CREATE TABLE `table_name` LIKE `old_table_name`;
--Change collations as you like
ALTER TABLE `table_name`
CHANGE `column_name1` `column_name1` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL,
CHANGE `column_name2` `column_name2` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL;
-- Import the data
INSERT INTO `table_name` (`id`,`column_name1`,`column_name2`,`column_name3`)
SELECT `id`,
CONVERT(CONVERT(_latin1 `column_name1` USING binary) USING utf8) collate utf8_unicode_ci,
CONVERT(CONVERT(_latin1 `column_name2` USING binary) USING utf8) collate utf8_unicode_ci,
`column_name3`
FROM `old_table_name`