More than once, my colleagues asked me the same question. here is the simplest PHP implementation. If you have a better method, share the following code: [php] & lt ;? Php $ db_host & quot; 192.168.1.10 & quot; $ db_user & quot; root & quot; $ db_psw & quot; 11111 & quot; $ db_name & q
More than once, my colleagues asked me the same question. here is the simplest PHP implementation. If you have a better method, please share with us :)
The code is as follows:
[Php]
$ Db_host = "192.168.1.10 ";
$ Db_user = "root ";
$ Db_psw = "11111 ";
$ Db_name = "csvimport ";
$ Conn = mysql_connect ($ db_host, $ db_user, $ db_psw) or die ("Connection occur error ");
Mysql_select_db ($ db_name, $ conn) or die ("Connection occur error ");
Mysql_query ("set names UTF-8 ");
Mysql_query ("load data infile '/root/bill20120813121249.csv 'into TABLE 'billdata' fields terminated ', 'enabled by' \ "'elasticed by' \" 'lines TERMINATED by' \ r \ n' IGNORE 1 LINES; ") or die ('Error :'. mysql_error ());
?>