How to import an excel file from a mysql tutorial
The simplest method is to use the php tutorial myadmin to directly import the xls file. This is not much to mention. Let's take a look at the following two methods to combine the php mysql command with the shell.
Method 1:
Select * into outfile './zhutiai.xls' from zhutiai where 1 order by id desc limit 0, 50;
Method 2:
Echo "select id, name from zhutiai where 1 order by id desc limit 0, 50; "|/usr/local/mysql/bin/mysql-h127.0.0.1-uroot-p123456>/data/zhutiai.xls
Because the default office Code is gb2312, the server generates UTF-8 encoding, which may cause Chinese characters to be exported to garbled characters. The solution is as follows:
Method 1. Use iconv on the server side for encoding conversion
Iconv-futf8-tgb2312 -ozhutiai2.xls zhutiai.xls
4.1.2.open zhutiai.xls in text format, save it as, select ansi encoding in encoding, and save
If method 1 fails to be converted, the following error occurs: iconv: illegal input sequence at position 1841,
Download zhutiai.xls first. The file is UTF-8 encoded and opened in excel with garbled characters.
Open zhutiai.xls in text format, save it as, select ansi encoding in encoding, and save