Docker ubuntu MySQL database input Chinese garbled solution

Docker ubuntu MySQL database input Chinese garbled solution

Cause:

The mysql service was started in the docker of the server, and the Chinese in the result showed garbled characters. I checked a lot of methods on the Internet to solve the database settings of ubuntu or centos, and did not modify the database settings in docker separately.

Solution

The solution is to execute the following sentence (written directly at the top of the SQL file) before sending the query:
SET NAMES'utf8';

It is equivalent to the following three instructions:

SET character_set_client = utf8;
SET character_set_results = utf8;
SET character_set_connection = utf8;

Then re-run the sql file to generate the table!

postscript

I haven't found a way to modify the mysql service directly in docker, because the mysql5.7 image downloaded by my docker cannot download vi/vim, which is really annoying.

Guess you like

Origin blog.csdn.net/u012140251/article/details/98733736