The reason why MySQL has Chinese garbled characters is because
1. Server itself setting problem, generally latin1
2. There is no encoding format specified when building the database and table.
Solution to Chinese garbled Chinese characters in form input data in MySql:
1. When building the database
CREATE DATABASE test CHARACTER SET 'utf8' COLLATE 'utf8_general_ci';
2. When creating a table
CREATE TABLE content ( text VARCHAR(100) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Basically there will be no problems, that is, the same encoding format will be used when building databases and tables.
1. View the default encoding format:
show variables like "%char%";
The following is the modified version
mysql> show variables like "%char%"; +--------------------------+---------------------------------------------------------+ | Variable_name | Value | +--------------------------+---------------------------------------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | /usr/local/mysql-5.7.13-osx10.11-x86_64/share/charsets/ | +--------------------------+---------------------------------------------------------+ 8 rows in set (0.01 sec)
2. Check the encoding format of the test database:
The above is the solution to the problem of Chinese garbled characters in form input data in MySql introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support of the website!