كيف أن يحوّل [شركتر-ست] وعمليّة فرز من [ووردبرسّ] قاعدة معطيات
منذ ذلك الحين [ووردبرسّ] 2.2, يساند [ووردبرسّ] سمة أنّ يسمح المستعملة أن يعيّن كلا ال [ووردبرسّ] قاعدة معطيات [شركتر-ست] وعمليّة فرز صنّفت مع [دبشرست] و [دبكلّت] قيم في [وب-كنفيغ.فب]. مع هذا قيم يعيّن, سيستعمل [ووردبرسّ] ال يعيّن قاعدة معطيات [شركترست] ([شرست]) وقاعدة معطيات عمليّة فرز ([إي.]. صنّفت أمر من الحرف, أرقام, ورموز من [شركتر-ست]) عندما يربط قاعدة معطيات طاولات.
مهما, في يتواجد [ووردبرسّ] تجهيزات أنّ يكون حسنت من صيغة مبكّرة [ووردبرسّ] أو لا بوضوح يثبت [أونيكد] [أوتف-8] [شرست] عمليّة فرز, التقصير قاعدة معطيات ثبتت [شركتر-ست] عادة فوق ك [لتين1] (تقصير على كلّ [مسقل] تجهيز تقريبا) مع [لتين1سوديشس] عمليّة فرز. إن أنت تركض مزدوج لغة أو [بلوغ] متعدّد لغات مع [ووردبرسّ], أنت يمكن واجهت مشكلة على رمز [إنكدينغ] عندما ك [بلوغ] كتبت موقعات في أخرى [فورين لنغج], أو عندما أنت تصدق ونسخة احتياطيّة القاعدة معطيات ومحاولة متأخّرة أن [ر-يمبورت] القاعدة معطيات تخليص [إين ث فنت وف] قاعدة معطيات إخفاق أو نادلة هجرة ويتحرّك. العرض واضحة, ك [ووردبرسّ] موقعات أو صفحات يريدون يحتوي يشوّه, غريبة ورموز مضحكة, حصص صحيحة يوما ما من????? ([قوسأيشن مرك]), يرجع [ووردبرسّ] قاعدة معطيات مع ك يستعصي عمل نافعة وإنتاج غيرمفهوم. (شهر ماي سبب أيضا جانبا خاطئة [شرست] عمليّة فرز)
الحل جيّدة إلى الرمز يرمّز مشكلة في [ووردبرسّ] أن يحوّل ال [شرست] أو قاعدة معطيات وعمليّة فرز إلى [أوتف-8] أو [أونيكد]. مهما, أنت يستطيع لا ببساطة ربطت إلى [مسقل] عن طريق قشرة قذيفة أو سيحوّل [فبمدمين] ويأمل كلّك نصوص جيّدا. بما أنّ يفسّر جانبا [ووردبرسّ] قاعدة معطيات تحويل مرشدة, مهتدية يتطلّب [شركتر-ستس] يستعمل ال [مسقل] يغيّر طاولة أمر. عندما يحوّل ال [شركتر-ستس], كلّ نص (ومماثلة) حوّلت مجالات إلى [أوتف-8], غير أنّ أنّ تحويل سيكسر نص موجودة لأنّ التحويل يتوقّع المعطيات أن يكون في [لتين1], غير أنّ [ووردبرسّ] يمكن يتلقّى خزّنت [أونيكد] رموز في [لتين1] قاعدة معطيات, و [أس ا رسولت], معطيات استطاع أنهيت فوق كنفاية بعد تحويل!
يزوّد المرشدة جدّا خشنة ومرشدة غامضة كحل على كيف أن واقعيّا حوّلت [ووردبرسّ] [مسقل] قاعدة معطيات طاولات من واحدة [شركتر-ست] إلى آخر, عادة [أوتف-8]. مهما, يعمل المرشدة واقعيّا, رغم أنّ العملية يستطيع كنت طويلة. أن يحوّل, ال [ستبس] يتضمّن عموما أن يغيّر كلّ نص ومجالات متّصلة في كلّ [وب] طاولات إلى نقطة, بعد ذلك يغيّر ال [شركتر-ست] القاعدة معطيات وأخيرا يغيّر النقطة مجالات [بك تو] نص. ينظر يتيح, غير أنّ [هوو لونغ] هو أخذ إلى مهتدية هكذا كثير مجالات على هكذا كثير طاولات? Furthermore, you will also need to remember the original type and length or values of all fields.
andersapt has posted a conversion script named convert_to_utf8_sql_generator.txt which automatically generates a list of SQL statements and commands need to fully convert your WordPress database to UTF8 based on the guide. However, there seems to be a minor bug with the script, although the author claimed it worked, where in my case, it simply won’t generate the list of SQL commands to run due to the error “PHP Fatal error: Call to a member function get_results() on a non-object in convert.php on line 37″. Once fixed, with this script in hand we can easily and quickly convert the database, tables and fields to use utf8_general_ci collation.
Note: I have tried out UTF-8 Database Converter plugin, but it’s a failure. It seemed like the author change to character set directly.
Guide to Convert WordPress Database Character Set to UTF8 (Unicode)
- Take the WordPress blog offline by placing a out-of-service or maintenance notice.
- Backup database - this is very important, nothing is guaranteed to work. If you’re using cPanel or other control panel, it’s best to perform a database backup from the control panel itself, where you can restore the database in one piece instead of by SQL statements, in the case of normal dump.
- Download the fixed convert_to_utf8_sql_generator.txt script and save it with a PHP extension.
- Modify the script to input the database name your WordPress blog is using. Locate the following text:
Tables_in_DATABASENAME
The DATABASENAME in red is the only thing that you need to change to match your WordPress database name. It should looks like this after change, for instance,
Tables_in_wp_mydigitallife
- Upload the convert_to_utf8_sql_generator.php (or you can rename to a shorter name such as convert.php) to the base root WordPress installation directory, where wp-config.php is also located.
- Now, call and browse the script from any web browser. To do this, simply add convert_to_utf8_sql_generator.php (or any name you give to the script) to the end of your blog URL (i.e http://www.mywebsite.com/convert_to_utf8_sql_generator.php) and press Enter. A long list of SQL statements will be generated on the web page.
- Ensure that your post_content and post title fields on wp_posts table DOES NOT belongs to any indexes or FULLTEXT indexes. Else the type of the fields may not be converted to BLOB with one of the errors list below. Some plugins, such as related posts tend to add indexes to these fields. In this case, temporarily drop the indexes.
ERROR 1170 (42000): BLOB/TEXT column ‘post_content’ used in key specification without a key length
ERROR 1283 (HY000): Column ‘post_content’ cannot be part of FULLTEXT index
- Login to your server shell by Telnet or SSH. You can skip this part of using Unix shell if you intend to use phpMyAdmin to do the dirty work, but I have not tried it. So if you do, do feedback on whether it can be done.
- Connect to MySQL server from the shell.
- Issue the following command first in MySQL prompt:
use DATABASENAME;
Again, replace DATABASENAME in red to the actual WordPress database name.
- Then copy and paste the whole list of SQL statements auto generated by the conversion script, and paste them into the MySQL prompt. Each and every SQL command should now be processed and executed by MySQL one by one. You may need to press Enter key to finish off the last one.
- During the processing, the similar error messages related to key length as mentioned may appears. In my case, the conversion to BLOB failed with such message in the following fields:
wp_categories.category_nicename
wp_comments.comment_approved
wp_links.link_visible
wp_options.option_name
wp_postmeta.meta_key
wp_posts.post_status
wp_posts.post_name
wp_posts.post_type
wp_usermeta.meta_key
wp_users.user_loginAll these fields are unlikely to contains non-ASCII characters. And fields such as category_nicename (category slug) and post_name (post slug) have been URL encoded (where your URL with unsafe non-alphanumeric characters will be replaced with a percent (%) sign followed by two hex digits and spaces encoded as plus (+) signs). Initial encoding of byte codes and character assignments for UTF-8 is consistent with ASCII, so direct conversion of these fields to UTF8 should not bring too much problem.
- Edit the wp-config.php file to add in DB_CHARSET and DB_COLLATE definitions. Add the following two lines, preferably under the section of MySQL Settings:
define(’DB_CHARSET’, ‘utf8′);
define(’DB_COLLATE’, ”);As explained in WordPress Codex, DB_COLLATE is left blank (null) so that the database collation will be automatically assigned by MySQL based on the database character set.
- Recreate the indexes and/or FULLTEXT indexes been dropped, if any.
- Activate the blog back into production mode.
- Check your blog to see if everything and every characters is okay.
- Delete the PHP script.
IMPORTANT: This is a machine translated page which is provided "as is" without warranty. Machine translation may be difficult to understand. Please refer to original English article whenever possible.
Share and contribute or get technical support and help at My Digital Life Forums.
Related Articles
- WordPress Charset Encoding Problem After Upgrading to Version 2.2
- How to Backup and Restore (Export and Import) MySQL Databases Tutorial
- IMP-00016 Required Character Set Conversion Not Supported Error when Import to Oracle Database
- WordPress 2.2 Released for Free Download
- Oracle EXP-00091 Error When Export Database
- Disable and Turn Off Post Revisions Tracking in WordPress 2.6 or Above
- Check and Optimize MySQL Database Automatically with Crontab/Cron
- How to Customize, Modify or Change WordPress Database Connection Error Page
- Download WordPress 2.3 Release Candidate 1 (RC1) with Tags Support
- How to Move WordPress Blog to New Domain or Location

































June 23rd, 2007 04:27
Hi…
I have to say (in my favor) that m not changing directly the database character set, please review my plugin and you will see that first it will convert your database binary and them to utf8 and finally it will put everything like before encoding but obviously with the UTF-8 character set…
I prefer to do and a..
ALTER TABLE table_name CONVERT TO CHARACTER SET binary
Than just make a mysql sentence for every text/string field, because as you can see the problems comes with key and some index value and the BLOB field type change.
Converting truth the sentence that my plugin use will transform all char to binary, all varchar to varbinary, all text (tynitext, text, mediumtext, longtext) to his binary representations (tinyblob, blob, mediumblob, longblob) and finally just set enum and set types with the collation binary.
I just came here to say this in favor and by the way the majority of the problems of my plugins are related to host configurations and other things that obviously i can control.
BTW its a better to solution to avoid problems of key and index by just setting the correct binary representation rather than using blob in all the way.
Greetings from mexico and sorry for all mistyping problems.
July 11th, 2007 16:00
[...] MySQL 本身的問題,便一知半解地去亂 set,結果一樣。。。 (5:00) 直至我讀完這篇文章,發現是 WP 由 2.1 升至 2.2.1 之後,閱讀 db 的 script 真的變了,讀不了 SQL db [...]
July 21st, 2007 15:33
[...] If this case, use –default-character-set=charset_name option to specify the character set or convert the database to UTF8. Get help or contribute tips or tricks at My Digital Life [...]
September 4th, 2007 18:57
[...] die Schnauze. Mit etwas mehr Hartnäckigkeit bei der Suche konnte ich am Ende dann doch noch eine passende Konvertierungsanleitung finden, die auf mystische Art und Weise sowohl auf das fehlerhafte Plugin hinweist, als auch die [...]
September 16th, 2007 02:04
Why don’t you just link the file directly here?
It is pain to register just to download the file.
September 16th, 2007 03:15
[...] to convert my database to UTF8 so my blog doesn’t look funny. The plugin didn’t work, another site requires registration (how lame), so I came up with my own solution which is KISS all the [...]
September 16th, 2007 03:59
Hi Chris, sorry for inconveniences, it’s so that users can discuss any bugs on the script on the forum when needed.
September 29th, 2007 03:23
[...] la codificación de acentos, ñ y símbolos para que funcionara bien. Para problemas recomiendo este artículo que indica los pasos para convertir tu bbdd a codificación [...]
November 17th, 2007 07:55
[...] ponga, siempre hay algo que me va a salir desconfigurado: los posts o los comentarios. He probado
November 19th, 2007 03:35
[...] ficheiro wp-config.php e deixar os valores das constantes DB_CHARSET e DB_COLLATE em branco. Outra solução é converter a base de dados toda para UTF-8, o que para mim já soa a [...]
December 14th, 2007 03:05
Hi, it worked fine for me using MyPHPAdmin.
Thanks for the article.
February 27th, 2008 01:20
I’m using PHPmyAdmin and try to convert my database to utf-8, but…PHPmA interrupts the process with the first error message (concering key length as mentioned in ur guide).
Is there a way to make PHPmA ignore errors / to proceed the other tables?
Thx in advance!
March 2nd, 2008 01:52
[...] How to convert character set and collation of wordpress database? [...]
March 19th, 2008 03:32
I must applaud you for publishing this. After hours of searching for an easy solution, when my provider moved my database to an “upgraded” platform, I was able to follow your instructions and and get the character set changed. I used the phpmyadmin to execute the code and deleted the lines that had errors. It ran perfectly and I only needed to edit a few slugs that had odd character in them. Fabulous!
March 31st, 2008 13:09
[...] How to Convert Character Set and Collation of WordPress Database Guide to Convert WordPress Database Character Set to UTF8 (Unicode) — » My Digital Life [...]
June 19th, 2008 12:19
[...] with troubleshooting the issue of not able to use the 2 lines in the wp-config.php file. Tried this method, but it didn’t work. Then I read up the idea of converting the SQL in a text editor. [...]
July 24th, 2008 18:53
I’ve uploaded an extended script to the thread. It handles cases where the tables and columns are utf8 but the strings inside are latin1. This happens when the tables are created as utf8 but the wp-config.php is missing DB_CHARSET and DB_COLLATE variables.