select into outfile用法

SELECT ... FROM TABLE_A
INTO OUTFILE "/path/to/file"
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n';

load data infile用法

LOAD DATA INFILE "/path/to/file" INTO TABLE table_name;
注意:如果导出时用到了FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n'语句,那么LODA时也要加上同样的分隔限制语句。还要注意编码问题。

解决select into outfile,不能导出到自定义目录问题

Recent Ubuntu Server Editions (such as 10.04) ship with AppArmor and MySQL's profile might be in enforcing mode by default. You can check this by executing sudo aa-status like so:

> sudo aa-status
5 profiles are loaded.
5 profiles are in enforce mode.
/usr/lib/connman/scripts/dhclient-script
/sbin/dhclient3
/usr/sbin/tcpdump
/usr/lib/NetworkManager/nm-dhcp-client.action
/usr/sbin/mysqld
0 profiles are in complain mode.
1 processes have profiles defined.
1 processes are in enforce mode :
/usr/sbin/mysqld (1089)
0 processes are in complain mode.

If mysqld is included in enforce mode, then it is the one probably denying the write. Entries would also be written in /var/log/messages when AppArmor blocks the writes/accesses. What you can do is edit /etc/apparmor.d/usr.sbin.mysqld and add /data/ and /data/* near the bottom like so:

/usr/sbin/mysqld {
...
/var/log/mysql/ r,
/var/log/mysql/* rw,
/var/run/mysqld/mysqld.pid w,
/var/run/mysqld/mysqld.sock w,
/data/ r,
/data/* rw,
}

And then make AppArmor reload the profiles.

> sudo /etc/init.d/apparmor reload

MySQL select into outfile用法的更多相关文章

  1. MySQL select into outfile 和 load data infile数据跨库转移

    select into outfile用法 SELECT ... FROM TABLE_A INTO OUTFILE "/path/to/file" FIELDS TERMINAT ...

  2. Mysql select into outfile 命令

    [1]Mysql select into outfile命令 在Mysql中,与load data infile命令作用相反的一个命令是select into outfile命令 select int ...

  3. mysql SELECT INTO OUTFILE ,can't create file (转)

    原文  http://blog.sina.com.cn/s/blog_6a5e34ad0100zfbi.html (转) 命令行模式进入mysql #mysql -uroot -p12345 #sel ...

  4. mysql高效导入导出load data [infile][outfile]用法

    一.MySQL高效导入数据的方法load data infile load data infile语句从一个文本文件中以很高的速度读入一个表中.使用这个命令之前,mysqld进程(服务)必须已经在运行 ...

  5. select into outfile 与 load data infile

    select into outfile用法 MySQL中,可以使用SELECT...INTO OUTFILE语句将表的内容导出为一个文本文件. SELECT [列名] FROM table [WHER ...

  6. Mysql备份--mysqldump&outfile

    1.备份工具mysqldump 客户端和服务器端都能用select outfile 只能写到服务器端 2.按表单位备份 a.单个表备份 mysqldump -uusername -p database ...

  7. MySQL select into 和 SQL select into

    现在有张表为student,我想将这个表里面的数据复制到一个为dust的新表中去,虽然可以用以下语句进行复制,总觉得不爽,希望各位帮助下我,谢谢.  answer 01: create table d ...

  8. mysql load data infile的使用 和 SELECT into outfile备份数据库数据

    LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name.txt' [REPLACE | IGNORE] INTO TABLE t ...

  9. mysql SELECT FOUND_ROWS()与COUNT(*)用法区别

    在mysql中 FOUND_ROWS()与COUNT(*)都可以统计记录,如果都一样为什么会有两个这样的函数呢,下面我来介绍SELECT FOUND_ROWS()与COUNT(*)用法区别   SEL ...

随机推荐

  1. bzoj1296: [SCOI2009]粉刷匠

    dp. 用到俩次dp,用1和0代表俩种颜色,首先对于每块木板我们进行一次dp,g[i][j]代表前j个格子刷i次最多能涂到几个格子. 则 g[i][j]=max(g[i-1][k],max(cnt[j ...

  2. Struts框架搭建时所遇到的问题

    问题一:Unable to load configuration. - bean - jar:file:/D:/Tomcat%206.0/webapps/bar/WEB-INF 原       因:可 ...

  3. Java 7 语法新特性

    一.二进制数字表达方式 原本整数(以60为例)能够用十进制(60).八进制(074).十六进制(0x3c)表示,唯独不能用二进制表示(111100),Java 7 弥补了这点. public clas ...

  4. [Sciter系列] MFC下的Sciter–4.HTML与图片资源内置

    [Sciter系列] MFC下的Sciter–4.HTML与图片资源内置,防止代码泄露. 本系列文章的目的就是一步步构建出一个功能可用,接口基本完善的基于MFC框架的SciterFrame程序,以此作 ...

  5. C扩展Python - official docs - defining new type

    1. Code & Official_doc: THIS 2. My question. #include <Python.h> /* * 1.PyTypeObject doc, ...

  6. Java [Leetcode 204]Count Primes

    题目描述: Description: Count the number of prime numbers less than a non-negative number, n. 解题思路: Let's ...

  7. LeetCode: JumpGame 1 and 2

    Title : Given an array of non-negative integers, you are initially positioned at the first index of ...

  8. 四、oracle基本sql语句和函数详解

    一.oracle常用数据类型 一.  数据定义语言(ddl) 数据定义语言ddl(data definition language)用于改变数据库结构,包括创建.更改和删除数据库对象. 用于操纵表结构 ...

  9. 关于KOBE 退役

    今天在网上看到一行话,写在KOBE 退役之际 关于职业,最值得问的是自己我有没有像科比那样始终表现出对团队的忠诚和对职业的热爱?从不被别人的误解和攻击打倒?在团队最困难的时候站出来做能做的一切?用职业 ...

  10. 解决:Unable to connect to repository https://dl-ssl.google.com/android/eclipse/site.xml

    ailed to fectch URl https://dl-ssl.google.com/android/repository/addons_list.xml, reason: Connection ...