1.保证MySQL 版本高于 5.5.3
2.确保mysql-connector-java-版本高于5.1.1-bin.jar
3.正确配置数据库 utf8mb4
注意 innodb_large_prefix 、innodb_file_format
检查是否正确
创建UTF8MB4数据库、及测试数据表是否正常插入表情
接下来正常的OFBiz导表流程
如果出现
Specified key was too long; max key length is 767 bytes 或 java.sql.SQLException -> Index Column Size too large。
Maximum Column Size is 767 Byte
--
That error means you are trying to add unique index on a varchar(255) utf8mb4 column. In utf8mb4 column, each character needs 4 bytes. So 255 characters means 1020 bytes. The max key length is 767 bytes.
增加 fieldtypemysql_utf8mb4.xml
详见附件
修改 entityengine.xml
详见附件
使配置适用 Utf8mb4
确保VISIT 等长字段业务正常使用即可。
2.确保mysql-connector-java-版本高于5.1.1-bin.jar
3.正确配置数据库 utf8mb4
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
default-character-set = utf8mb4
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
collation-server = utf8mb4_general_ci
init-connect=?.ET NAMES utf8mb4?
character-set-server = utf8mb4
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
#
# * Fine Tuning
#
key_buffer = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover = BACKUP
#max_connections = 100
#table_cache = 64
#thread_concurrency = 10
#
# * Query Cache Configuration
#
query_cache_limit = 1M
query_cache_size = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
#log_slow_queries = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id = 1
#log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem
innodb_file_format = Barracuda
innodb_file_format_max = Barracuda
innodb_large_prefix = 1
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[mysql]
#no-auto-rehash # faster start of mysql but no tab completition
default-character-set = utf8mb4
[isamchk]
key_buffer = 16M
#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
注意 innodb_large_prefix 、innodb_file_format
检查是否正确
show variables like '%character%';
show variables like 'innodb_large_prefix';
show variables like 'innodb_file_format';
创建UTF8MB4数据库、及测试数据表是否正常插入表情
create database databaseName CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
use databaseName;
create table test (value varchar(255));
insert into asdf values ('表情');
#此处无法粘贴进来。自己找
接下来正常的OFBiz导表流程
如果出现
Specified key was too long; max key length is 767 bytes 或 java.sql.SQLException -> Index Column Size too large。
Maximum Column Size is 767 Byte
--
That error means you are trying to add unique index on a varchar(255) utf8mb4 column. In utf8mb4 column, each character needs 4 bytes. So 255 characters means 1020 bytes. The max key length is 767 bytes.
增加 fieldtypemysql_utf8mb4.xml
详见附件
修改 entityengine.xml
详见附件
使配置适用 Utf8mb4
确保VISIT 等长字段业务正常使用即可。