Mysql source imports garbled solutions: 1. Use the "mysql -u guoxingege -p --default-character-set=utf8mb4" command to set the encoding; 2. Use "mysql -u guoxingege -p -- "default-character-set=utf8" command can be used to set the encoding.
The operating environment of this tutorial: Windows 10 system, MySQL version 5.7, Dell G3 computer.
What should I do if mysql source imports garbled characters?
MySQL uses the Source command to import Chinese garbled characters
Solution: add encoding
mysql -u guoxingege -p --default-character-set=utf8mb4
or
mysql -u guoxingege -p --default-character-set=utf8
other encoding customization## when logging in
#Press enter and enter the passwordThe following operations are nothing more thanuse your database;source /xx/xxx.sql;Relevant expansion: The mysql source command is mainly used to pour very large sql files. In daily work, we often encounter the situation of importing large data files. In MySQL, use mysql source Commands can be imported to easily solve this problem. The basic syntax of MySQL source is as follows:
mysql>use dbtest; mysql>set names utf8; mysql>source D:/xxx/xxx/back.sql;First we select the database to which we need to import data, and then set the default characters. Set, then use the source command, followed by the absolute path where our .sql is located. If we have 5 files, we can pour them into the database one by one in this way. Remember to select the correct database name. Recommended learning: "
MySQL Video Tutorial"
The above is the detailed content of What should I do if mysql source imports garbled characters?. For more information, please follow other related articles on the PHP Chinese website!