Play Framework MySQL Unified UTF8

Source: Internet
Author: User

form submission in the Text field, using the default settings, garbled.

All unified for UTF8. The server is CentOS, only demo, no other platform browser encoding is considered.

1. Change the MySQL-related configuration to UTF8 completely. Vim/etc/my.cnf


[mysqld]datadir=/var/lib/mysql#datadir=/home/mysqlsocket=/var/lib/mysql/mysql.sock#socket=/home/mysql/ mysql.sockuser=mysql# disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0[mysqld _safe] #log-error=/var/log/mysqld.loglog-error=/var/log/mysqld.log#pid-file=/var/run/mysqld/mysqld.pidpid-file= /var/run/mysqld/mysqld.pid#add by userdefault-character-set=utf8[mysqld]init_connect= ' Set NAMES UTF8 ' Default-character-set=utf8[mysql]default-character-set=utf8
2. Create a database UTF8



reate DATABASE ' databasename ' CHARACTER SET ' utf8 ' COLLATE ' utf8_general_ci ';

3. Creating tables is also UTF8

CREATE TABLE IF not EXISTS suploadfileinfo (ID int. auto_increment PRIMARY key not Null,filename VARCHAR (255), FileSize    VARCHAR (255), Time TIMESTAMP default now ()) Engine=innodb   default   Charset=utf8;
4. The play framework is also UTF8 when MySQL is connected. Conf/application.conf
db.default.driver= com.mysql.jdbc.driverdb.default.url= "Jdbc:mysql://localhost/machinelearning?useunicode=true &characterencoding=utf-8 "Db.default.username=rootdb.default.password=" "






Play framework MySQL unified UTF8

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.