Solution to garbled characters when importing data to the mysql database through command lines:
Open the SQL file and add the following content to the first line of the SQL file:
/*! 40101 set names utf8 */;
Save SQL file as UTF-8 NO BOM format
Upload the SQL file over ftp and put it in the root directory.
Go to your cPanel, see the cron jobs icon, click in, and select Advanced (Unix Style)
Because it only needs to be run once, Minute, Hour, Day, and Month are all filled in with the specific time to be run, leave the remaining two minutes (if the VM is not local, you can check the host time on FTP.) fill in the * number for Weekday. Enter the Command to be run, that is, the import Command:
Mysql-u username-p password [-h database host] database <Database Backup. SQL
Assume that the IP address of the remote host is 10.0.0.1, the user name is root, and the password is 123. Enter the following command:
Mysql-h10.0.0.1-uroot-p123
Note:
You do not need to add spaces to u and root. The same applies to others. For example, my settings are as follows:
Mysql-ucpanel123_cpuser-pcpanel-hlocalhost cpanel123_cp
Then, view the import information in phpMyAdmin. Importing SQL files in this way is very fast. I wish you success.