Troubleshooting MySQL database does not support Chinese

Source: Internet
Author: User

After migrating a set of internal systems (confluence), the page opened and found that the question mark was garbled. Analysis Reason:

I created the database in the following way:

Mysql> CREATE database Confluence character set UTF8 collate utf8_bin;

Query OK, 1 row Affected (0.00 sec)


Mysql> Grant all on conflence.* to ' confluence ' @ ' percent ' identified by ' 456456 ';

Query OK, 0 rows Affected (0.00 sec)


Mysql> Grant all on confluence.* to ' confluence ' @ ' localhost ' identified by ' 456456 ';

Query OK, 0 rows Affected (0.00 sec)


mysql> flush Privileges;

Query OK, 0 rows Affected (0.00 sec)

Already set the character set to Utf-8, why still garbled.

Look at the encoding format of the database as follows:

Mysql> Show variables like '%char% ';

+--------------------------+----------------------------+

| variable_name | Value |

+--------------------------+----------------------------+

| character_set_client | UTF8 |

| character_set_connection | UTF8 |

| Character_set_database | UTF8 |

| Character_set_filesystem | binary |

| Character_set_results | UTF8 |

| Character_set_server | Latin1 |

| Character_set_system | UTF8 |

| Character_sets_dir | /usr/share/mysql/charsets/|

+--------------------------+----------------------------+

8 rows in Set (0.00 sec)

To find the cause of the problem, Character_set_server does not support UTF8, modifies the MySQL configuration and reloads it.

    1. /etc/init.d/mysqld stop

    2. Vi/etc/my.cnf

Add to:

Character_set_server=utf8

init_connect= ' SET NAMES UTF8 '

3./etc/init.d/mysqld Start

To view the database encoding character set:

Mysql> Show variables like '%char% ';

+--------------------------+----------------------------+

| variable_name | Value |

+--------------------------+----------------------------+

| character_set_client | UTF8 |

| character_set_connection | UTF8 |

| Character_set_database | UTF8 |

| Character_set_filesystem | binary |

| Character_set_results | UTF8 |

| Character_set_server | UTF8 |

| Character_set_system | UTF8 |

| Character_sets_dir | /usr/share/mysql/charsets/|

+--------------------------+----------------------------+

8 rows in Set (0.00 sec)

Re-import the previous data, the interface returned to normal.

Tips:

Be sure to modify the URL when configuring confluence to connect to the MySQL database:

Original such as:

Jdbc:mysql://localhost/confluence?sessionvariables=storage_engine%3dinnodb</property>

Have Chinese, must let it support UTF8, otherwise the default is latin1, need to modify the name as follows:

Jdbc:mysql://localhost/confluence?autoreconnect=true&amp;useunicode=true&amp;characterencoding=utf8 &amp;sessionVariables=storage_engine%3DInnoDB</property>

Using Unicode encoding, the character encoding is UTF-8 and is automatically re-connected.

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/76/D3/wKiom1ZdOOKQVjUdAABtqG9Djac862.png "title=" Haha.png "alt=" Wkiom1zdookqvjudaabtqg9djac862.png "/>

This article is from the "7159900" blog, please be sure to keep this source http://7169900.blog.51cto.com/7159900/1718486

Troubleshooting MySQL database does not support Chinese

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.