0

I have some MySQL Character Set Error. I'm Korean, So I need put Korean in MySQL Server. but I can't. I changed all character set, and send query "SET NAMES UTF8MB4" but My Program print again Same Error.

I try put "테스트" And Insert Into In Program (Pawn Language)

FormatEx(Query, sizeof(Query), "INSERT INTO %s_bans (type, ip, name, created, ends, length, reason, aid, adminIp, sid, country) VALUES \
                    (1, '%s', '', UNIX_TIMESTAMP(), UNIX_TIMESTAMP() + %d, %d, '%s', (SELECT aid FROM %s_admins WHERE authid = '%s' OR authid REGEXP '^STEAM_[0-9]:%s$'), '%s', \
                    (SELECT sid FROM %s_servers WHERE ip = '%s' AND port = '%s' LIMIT 0,1), ' ')",
        DatabasePrefix, ip, (minutes * 60), (minutes * 60), banReason, DatabasePrefix, adminAuth, adminAuth[8], adminIp, DatabasePrefix, ServerIp, ServerPort);

I try many search and test, I can't fix this error. Thanks!

Server OS : Ubuntu Server 16.04.3 64bit

MySQL Error :

L 09/11/2017 - 20:18:22: [sbpp_main.smx] Verify Insert Query Failed: Incorrect string value: '\xED \x85 \x8C ...' for column 'reason' at row 1

show variables like 'char%'; :

+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8mb4                    |
| character_set_connection | utf8mb4                    |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8mb4                    |
| character_set_server     | utf8mb4                    |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

show create table sb_bans (Target Table) :

| sb_bans | CREATE TABLE `sb_bans` (
  `bid` int(6) NOT NULL AUTO_INCREMENT,
  `ip` varchar(32) DEFAULT NULL,
  `authid` varchar(64) NOT NULL DEFAULT '',
  `name` varchar(128) NOT NULL DEFAULT 'unnamed',
  `created` int(11) NOT NULL DEFAULT '0',
  `ends` int(11) NOT NULL DEFAULT '0',
  `length` int(10) NOT NULL DEFAULT '0',
  `reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `aid` int(6) NOT NULL DEFAULT '0',
  `adminIp` varchar(32) NOT NULL DEFAULT '',
  `sid` int(6) NOT NULL DEFAULT '0',
  `country` varchar(4) DEFAULT NULL,
  `RemovedBy` int(8) DEFAULT NULL,
  `RemoveType` varchar(3) DEFAULT NULL,
  `RemovedOn` int(10) DEFAULT NULL,
  `type` tinyint(4) NOT NULL DEFAULT '0',
  `ureason` text,
  PRIMARY KEY (`bid`),
  KEY `sid` (`sid`),
  FULLTEXT KEY `reason` (`reason`),
  FULLTEXT KEY `authid_2` (`authid`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 |

MySQL Status :

mysql  Ver 14.14 Distrib 5.7.19, for Linux (x86_64) using  EditLine wrapper

Connection id:          54
Current database:
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.7.19-0ubuntu0.16.04.1 (Ubuntu)
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    utf8mb4
Conn.  characterset:    utf8mb4
UNIX socket:            /var/run/mysqld/mysqld.sock
Uptime:                 18 min 43 sec

Threads: 7  Questions: 1697  Slow queries: 0  Opens: 203  Flush tables: 1  Open                        tables: 118  Queries per second avg: 1.511

mysqld.cnf

[mysqld]
character-set-client-handshake=FALSE
init_connect="SET collation_connection = utf8mb4_general_ci"
init_connect="SET NAMES utf8mb4"
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci

[client]
default-character-set=utf8mb4

mysql.cnf

[mysql]
default-character-set = utf8mb4

mysqldump.cnf

[mysqldump]
default-character-set = utf8mb4
Darkhost
  • 9
  • 3
  • So… what string are you trying to insert, and how, and what encoding is it in? – deceze Sep 11 '17 at 12:14
  • @deceze I try "테스트", use insert into. and what meaning 'what encoding is it in'? Sry My Bad English :( – Darkhost Sep 11 '17 at 12:15
  • How do you connect to the database in [tag:pawn], where does the string come from you're trying to insert? This is much more about the pawn side than the MySQL side. We need more details on your pawn code, less of your MySQL server config. – deceze Sep 11 '17 at 12:27
  • @deceze https://github.com/sbpp/sourcebans-pp/blob/v1.x/game/addons/sourcemod/scripting/sbpp_main.sp / This is not my Program. I contact This Program's Developer before write here, developer can use this string but i can't – Darkhost Sep 11 '17 at 12:35

1 Answers1

0

Not enough info -- "print again Incorrect String Value"

  • 테스트 indicates Mojibake
  • `` indicates truncation
  • ????????? indicates something else.

See this for details about each.

Note: root (or any SUPER user) does not run init_connect. Whenever developing a database-based app, provide a non-root login.

In the error text, \xED \x85 \x8C, where there actually spaces as indicated? (utf8 is hex ED858C.) Where does FormatEx come from? Could it be that FormatEx inserted spaces??

Rick James
  • 135,179
  • 13
  • 127
  • 222
  • FormatEx is https://sm.alliedmods.net/new-api/string/FormatEx (This language's API), And I can only same Error - L 09/11/2017 - 20:18:22: [sbpp_main.smx] Verify Insert Query Failed: Incorrect string value: '\xED \x85 \x8C ...' for column 'reason' at row 1 – Darkhost Sep 12 '17 at 09:44
  • _Why would anybody use a language with caveats like "... this security check is removed ..." in these days of rampant hacking???_ – Rick James Sep 12 '17 at 15:10