Posts

Showing posts with the label charset

Connecting to MySQL 8 from Old PHP version using mysqli

If you have upgraded your MySQL to MySQL 8 version and still using older version of PHP you might encounter a few problems in the connection using mysqli connector library. 1. The first problem we are going to solve is: php mysql 8: "Server sent charset (255) unknown to the client. Please, report to the developers" The problem is that MySQL have changed the default character set from utf8 to utf8mb4 and it is not supported by mysqli connector (nor PDO as I have checked) in older versions of php. "The default collation for utf8mb4 differs between MySQL 5.7 and 8.0 ( utf8mb4_general_ci for 5.7, utf8mb4_0900_ai_ci for 8.0). When the 8.0 client requests a character set of utf8mb4 , what it sends to the server is the default 8.0 utf8mb4 collation; that is, the utf8mb4_0900_ai_ci." https://dev.mysql.com/doc/refman/8.0/en/charset-connection.html The way to solve it easily (there are other ways, such as upgrading php or connectors and more ...) is to force MySQL 8.0 to ...

UTF8 ובסיסי נתונים MySQL Database

זה כבר כמה זמן אני מעוניין לכתוב על ניהול נכון של Encoding בבניית אתרי אינטרנט. אנשים נוטים לבצע טעויות רבות ולא מבינים את המשמעות שבין UTF-8 לבין תקני ISO ותקנים של Windows כגון Windows-1255. הבעיות מופיעות בבחירה לא נכונה של Charset הן בבניית העמוד והן בשמירה ב - Database. לצערי אין לי את הזמן כרגע, אבל אני בוודאי שעוד אחזור לכך ואסביר את כל שלבי ה - Encoding מה - Datbase דרך ה - Webserver וכלה בדף ה- HTML והתצוגה בדפדפן. כרגע אני משתף קוד קצר ל - mysql שימיר לנו שדות טקסט ששמרנו בהם עברית ב - Charset latin1 ל - UTF8. ALTER TABLE files ADD COLUMN temp TEXT CHARACTER SET utf8 COLLATE utf8_general_ci AFTER text; -- add the temp column UPDATE files SET temp=CONVERT(CONVERT(text USING binary) USING utf8); -- convert the data to the new column ALTER TABLE files DROP COLUMN text; -- drop original column ALTER TABLE files CHANGE temp text TEXT CHARACTER SET utf8 COLLATE utf8_general_ci; -- rename temp column Change hebrew / or other charset inside MySQL to UTF-8.