Java deployment after Ubuntu Chinese display question mark question

Source: Internet
Author: User
Tags locale import database

1, first recall the coding format of their own projects, that is, the encoding format used in the local encoding. UTF-8
2. Detection of Tomcat setup issues, settings in Web. XML and server:
In Server.xml:

<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" /><Connector port="8009" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8"/>

The following content in Web. XML removes the comment:

<filter> <filter-name>setCharacterEncodingFilter</filter-name> <filter-Class>Org.Apache.Catalina.Filters.setcharacterencodingfilter</filter- class> <init-param> << Span class= "Hljs-title" >param-name>encoding</param-name> <param- value>utf-8</param-value> </init-param> <async-supported>true</ async-supported> </filter>  

3. Detect the encoding format in Ubuntu server

//检测本地语言环境:locale//进行配置的修改vi /etc/profile//添加下列行(LC_ALL表示全部设置,但不影响LANG):export LANG="en_US.UTF-8"export LC_ALL="zh_CN.UTF-8"//设置后使其起效source /etc/profile//当出现 cannot 错误时 ,使用以下命令进行安装相应语言包sudo locale-gen zn_CN.UTF-8//当起效后,要再次进入配置中修改,将刚添加的两行删除,不然会影响jdk环境

4, the configuration of MySQL
1. Modify the MySQL default configuration:
Default MySQL configuration: Server, client are latin1, Chinese is not supported, this is changed to UTF8
Method:
To modify a configuration file:

Vim/etc/mysql/my.cnf

[Mysqld]
Character-set-server=utf8
Collation-server=utf8_general_ci

Restart MySQL

/etc/init.d/mysql restart

Check the encoding method:

Mysql> Show variables like ' char% ';
+--------------------------+----------------------------+
| variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | UTF8 |
| character_set_connection | UTF8 |
| Character_set_database | Latin1 |
| Character_set_filesystem | binary |
| Character_set_results | UTF8 |
| Character_set_server | UTF8 |
| Character_set_system | UTF8 |
| Character_sets_dir | /usr/share/mysql/charsets/|
+--------------------------+----------------------------+
2. Modify the configuration of the database used by the project
Modifying this database is encoded as UTF8 (default is latin1)
mysql> ALTER DATABASE name character set UTF8;

To view the encoding for this database:
mysql> status

Connection id:41
current database:tslcrms
current user : [EMAIL&NBSP;PROTECTED]
ssl:not in use
current Pager: STDOUT
using outfile: '
using delimiter:;
server version:5.5.38-0ubuntu0.14.04.1 (Ubuntu)
protocol VERSION:10
connection:localhost via UNIX socket
server CHARACTERSET:UTF8
db characterset:utf8
client CHARACTERSET:UTF8
conn. CHARACTERSET:UTF8
unix Socket:/ VAR/RUN/MYSQLD/MYSQLD.SOCK
uptime:53 min. sec

Mysql> Show CREATE Database tslcrms;
+----------+------------------------------------------------------------------+
| Database | Create Database |
+----------+------------------------------------------------------------------+
| tslcrms | CREATE DATABASE 数据库名 /*!40100 DEFAULT CHARACTER SET UTF8 */|
+----------+------------------------------------------------------------------+

3. The encoding of the tables and fields in the Import database file is modified to UTF8
You can change the. sql file directly and finish the import.
You can also import, and then use the command to view and change.

Attached: Use the command to modify the character set in MySQL:
mysql> SET character_set_client = UTF8;

 mysql> SET character_set_connection = utf8 ; mysql> SET character_set_database = utf8 ; mysql> SET character_set_results = utf8 ; mysql> SET character_set_server = utf8 ; mysql> SET collation_connection = utf8 ; mysql> SET collation_database = utf8 ; mysql> SET collation_server = utf8 ;

SET NAMES ' UTF8 ';
Equivalent to the following three-sentence instruction:
SET character_set_client = UTF8;
SET character_set_results = UTF8;
SET character_set_connection = UTF8;

5. In addition
The default character set for MySQL is latin1, so change to UTF8. Many online articles perform "sudo vi/etc/mysql/my.cnf", but open a look that has two jargon inside:

!includedir /etc/mysql/conf.d/!includedir /etc/mysql/mysql.conf.d/

To think that the MySQL configuration file should be under those two folders, and then try to open the/etc/mysql/mysql.conf.d/under the Mysqld.cnf file, execute the following command:

~$ sudo vi/etc/mysql/mysql.conf.d/mysqld.cnf

[Client]
Default-character-set=utf8

[Mysqld_safe]
Socket =/var/run/mysqld/mysqld.sock
Nice = 0

[Mysqld]
Character-set-server=utf8
Collation-server=utf8_general_ci

After restarting the MySQL server
~$ sudo/etc/init.d/mysql Restart
~$ Mysql-u Root-p
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/|
+--------------------------+----------------------------+


Welcome to join the Learning Exchange Group 569772982, we learn to communicate together.

Java deployment after Ubuntu Chinese display question mark question

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.