Home > Article > Operation and Maintenance > What to do if mysql is garbled in docker
Solution to mysql garbled code in docker: 1. Create two directories, namely "/tmp/mysql/data" and "/tmp/mysql/conf"; 2. Write the "hmy.cnf" file ; 3. Create the container; 4. Use "docker ps -a" to check whether the creation is successful; 5. Enter the mysql container; 6. Test the connection successfully.
The operating environment of this tutorial: linux7.3 system, docker version 19.03, Dell G3 computer.
What should I do if mysql is garbled in docker?
Solution to the Chinese garbled code of MySQL running in Docker
1. First create two directories
mkdir /tmp/mysql/data mkdir /tmp/mysql/conf
2. Write the hmy.cnf file and write the following content to In the file
[mysqld] skip-name-resolve character_set_server=utf8 datadir=/var/lib/mysql server-id=1000 [mysql] default-character-set = utf8 [mysql.server] default-character-set = utf8 [mysqld_safe] default-character-set = utf8 [client] default-character-set = utf8 vi /hmy.cnf
3. Create the container
4. Check that the creation is successful
docker ps -a
5 , enter the mysql container
docker exec -it mysql2 /bin/bash
6. Test connection is successful
7. Check whether there are any Chinese garbled characters
Recommended learning: "docker video tutorial"
The above is the detailed content of What to do if mysql is garbled in docker. For more information, please follow other related articles on the PHP Chinese website!