V
V
Viktor Kachmaryk2020-04-15 10:50:52
MySQL
Viktor Kachmaryk, 2020-04-15 10:50:52

How to remove ERROR 1366 (HY000): Incorrect string value: '\xF4\xA9"\xDA\xA7\x0D...'?

My database has a table:
CREATE TABLE `customer` (
`customer_id` INT AUTO_INCREMENT,
`first_name` varchar(40) NOT NULL,
`last_name` varchar(40) NOT NULL,
`phone` varchar(30),
`email` varchar(50),
`street` varchar(50),
`city` varchar(50) DEFAULT "Lviv",
`state` varchar(50),
`zip_code` varchar(50),
`login` varchar(150) NOT NULL ,
`password` varchar(255),
PRIMARY KEY (`customer_id`)
);

I needed to make a trigger that encodes a password:
CREATE TRIGGER customer_password BEFORE
INSERT ON customer FOR EACH ROW
SET NEW.password = AES_ENCRYPT(NEW.password, 'test');

And when I try to insert an item into the table:
INSERT INTO customer VALUES (NULL, 'Petroror', 'Petro', NULL, '[email protected]', 'Zelena', 'Lviv', NULL, NULL, 'petros', 'mypass');

I get this error:
ERROR 1366 (HY000): Incorrect string value: '\xF4\xA9"\xDA\xA7\x0D...' for column 'password' at row 1

utfmb4 tried..

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2020-04-15
@Studik_001

https://dev.mysql.com/doc/refman/8.0/en/encryption...

and returns a binary string containing the encrypted output

And why is a binary piece of data incorrect data for a text field? Well, it's completely incomprehensible.
Use the appropriate data type.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question