假设客户端与MYSQL服务器不在同一机器

导入文件在客户端机器上/usr/jfy/tmp/scpcdr.txt,在客户机登录mysql后,执行下面导入语句:

LOAD DATA LOCAL INFILE  "/usr/jfy/tmp/scpcdr.txt" into table scpcdr fields TERMINATED by '|';

正常情况是可以成功的,如果出现提示:
ERROR 1148 (42000): The used command is not allowed with this MySQL version

这种情况一般是由于MySQL限制了客户端导入本地文件的权限,
mysql> show variables like 'local%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| local_infile  | OFF   |
+---------------+-------+
1 row in set (0.00 sec)

mysql> set global local_infile = 1;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'local%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| local_infile  | ON    |
+---------------+-------+
1 row in set (0.00 sec)

再执行导入就可以了。
Logo

更多推荐