1

I have a very big database with data stored on latin1 charsets.

On database with phpmyadmin if i use lines like this:

alter table TABLE_NAME modify FIELD_NAME blob;
alter database DATABASE_NAME charset=utf8;
alter table TABLE_NAME modify FIELD_NAME varchar(255) character set utf8;

All goes on. Text was converting.

But i have a lot of fields, tables. How to make it on all tables, fields? Is there a good convertation php script?

Also i uses on iconv, but no changes from latin1 to utf-8

Foxsk8
  • 308
  • 1
  • 9
  • 21
  • 2
    possible duplicate of [A script to change all tables and fields to the utf-8-bin collation in MYSQL](http://stackoverflow.com/questions/105572/a-script-to-change-all-tables-and-fields-to-the-utf-8-bin-collation-in-mysql) – M Khalid Junaid Sep 13 '13 at 14:31
  • 1
    Thanks for link. 5 hours spending to search right topic :) – Foxsk8 Sep 13 '13 at 15:01

1 Answers1

0
  1. create new database in utf8
  2. restore your database structure
  3. run "ALTER TABLE the_latin_one CONVERT TO CHARACTER SET utf8;" for all of your tables
  4. create php script that create sql.txt like this

file_put_contents(PATH2."sql.txt","insert into ". $TABLE[0]. " values(". (rtrim($q_col,",") ).");\n",FILE_APPEND);

really you must create all tables insert query. using "show FULL tables where Table_type<>'VIEW'" and "set character set 'latin1'" query may help you for do this. if you have any problem write a comment for me ;)

  1. in command line mysql -u xxx -p yourDB< sql.txt i do this and solve my problem after 3 years :))