MySQL Character Encoding Issues

These MySQL commands might come in handy when running up against character encoding issues:

mysql> use `your_database`;
Database changed
mysql> show variables like "collation_database";
+--------------------+-----------------+
| Variable_name      | Value           |
+--------------------+-----------------+
| collation_database | utf8_general_ci | 
+--------------------+-----------------+
1 row in set (0.00 sec)
mysql> show variables like "character_set_database";
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| character_set_database | utf8  | 
+------------------------+-------+
1 row in set (0.00 sec)
mysql> show create database `your_database`;
+---------------+------------------------------------------------------------------------+
| Database      | Create Database                                                        |
+---------------+------------------------------------------------------------------------+
| your_database | CREATE DATABASE `your_database` /*!40100 DEFAULT CHARACTER SET utf8 */ | 
+---------------+------------------------------------------------------------------------+
1 row in set (0.01 sec)
mysql> show create table `your_table`;
+------------+-----------------------------------------------------------------------------------------------------+
| Table      | Create Table                                                                                        |
+------------+-----------------------------------------------------------------------------------------------------+
| your_table | CREATE TABLE `your_table` (
  `test` varchar(255) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 | 
+------------+-----------------------------------------------------------------------------------------------------+
1 row in set (0.02 sec)

Tags:

Comments

Looks handy!

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.