Solution:
1. First enter msyql, and then use show variables like 'character%' to perform encoding display. You can see the following figure:
The default is that both the client and the server use latin1, so the characters will be garbled.
2. Modify the /opt/lampp/etc/my.cof file
Add the above statements under mysql, mysqld, and client respectively.
Note: If the error cannot be started after modification, try changing default-character-set=utf8
to character_set_server=utf8
; here I am I encountered this problem, so after removing the default, it was normal. default-character-set=utf8
was not used in the script.
3. Use the command drop database database name to delete the created database
4. Restart the mysql service:
/opt/lampp/lampp restart
5. Re-create the database and table structure, and insert again The data can be used normally
Recommended tutorial:linux tutorial
The above is the detailed content of Mysql garbled problem under linux. For more information, please follow other related articles on the PHP Chinese website!