首页 \ 问答 \ 使用SELECT INTO OUTFILE如何解决MySQL Errcode 13?(How can I get around MySQL Errcode 13 with SELECT INTO OUTFILE?)

使用SELECT INTO OUTFILE如何解决MySQL Errcode 13?(How can I get around MySQL Errcode 13 with SELECT INTO OUTFILE?)

我试图使用MySQL SELECT INTO OUTFILE语句将表的内容转储到csv文件。 如果我做:

SELECT column1, column2
INTO OUTFILE 'outfile.csv'
FIELDS TERMINATED BY ','
FROM table_name;

outfile.csv将在该数据库文件所在的同一目录中的服务器上创建。

但是,当我将查询更改为:

SELECT column1, column2
INTO OUTFILE '/data/outfile.csv'
FIELDS TERMINATED BY ','
FROM table_name;

我得到:

ERROR 1 (HY000): Can't create/write to file '/data/outfile.csv' (Errcode: 13)

Errcode 13是一个权限错误,但是即使我将/ data的所有权更改为mysql:mysql并给它777权限,我也得到它。 MySQL作为用户“mysql”运行。

奇怪的是,我可以在/ tmp中创建文件,只是在我尝试过的任何其他目录中,即使有权限设置,使得用户的mysql应该能够写入目录。

这是在Ubuntu上运行的MySQL 5.0.75。


I am trying to dump the contents of a table to a csv file using a MySQL SELECT INTO OUTFILE statement. If I do:

SELECT column1, column2
INTO OUTFILE 'outfile.csv'
FIELDS TERMINATED BY ','
FROM table_name;

outfile.csv will be created on the server in the same directory this database's files are stored in.

However, when I change my query to:

SELECT column1, column2
INTO OUTFILE '/data/outfile.csv'
FIELDS TERMINATED BY ','
FROM table_name;

I get:

ERROR 1 (HY000): Can't create/write to file '/data/outfile.csv' (Errcode: 13)

Errcode 13 is a permissions error, but I get it even if I change ownership of /data to mysql:mysql and give it 777 permissions. MySQL is running as user "mysql".

Strangely I can create the file in /tmp, just not in any other directory I've tried, even with permissions set such that user mysql should be able to write to the directory.

This is MySQL 5.0.75 running on Ubuntu.


原文:https://stackoverflow.com/questions/2783313
更新时间:2023-05-01 21:05

最满意答案

正确的国家代码是en_GB 。 区域使用ISO 3166-1的国家代码。 维基百科的写作包括:

根据ISO 3166 / MA,选择代码,以反映国家名称的重要而独特的组成部分,以便允许国家名称和国家代码之间的视觉关联。“[7] 因此,通常不会使用诸如“共和国”,“王国”,“联合”,“联邦”或“民主党”等国名的常用组成部分。 因此,例如,联合王国正式名称为“英国和北爱尔兰联合王国”(尽管英国是根据英国的要求而保留的)。


The correct country code is en_GB. Locales use ISO 3166-1 for country codes. The wikipedia writeup includes:

The codes are chosen, according to the ISO 3166/MA, "to reflect the significant, unique component of the country name in order to allow a visual association between country name and country code".[7] For this reason, common components of country names like "Republic", "Kingdom", "United", "Federal" or "Democratic" are normally not used for deriving the code elements. As a consequence, for example, the United Kingdom is officially assigned the alpha-2 code GB rather than UK, based on its official name "United Kingdom of Great Britain and Northern Ireland" (although UK is reserved on the request of the United Kingdom).

相关问答

更多
  • 正确的国家代码是en_GB 。 区域使用ISO 3166-1的国家代码。 维基百科的写作包括: 根据ISO 3166 / MA,选择代码,以反映国家名称的重要而独特的组成部分,以便允许国家名称和国家代码之间的视觉关联。“[7] 因此,通常不会使用诸如“共和国”,“王国”,“联合”,“联邦”或“民主党”等国名的常用组成部分。 因此,例如,联合王国正式名称为“英国和北爱尔兰联合王国”(尽管英国是根据英国的要求而保留的)。 The correct country code is en_GB. Locales us ...
  • 请参阅java.util和java.text的启用语言环境功能 ,以获取Oracle JDK 8和JRE 8所有支持的语言环境的列表。 未列出语言标记en-EN 。 这是因为作为国家代码(“EN”)提供的字符串不是指定的ISO 3166 alpha-2国家/地区代码 (请参阅区域设置 ,“国家(地区)”)。 可以使用Locale.getISOCountries()检索ISO 3166中定义的所有双字母国家/地区代码的列表。 See Enabled Locales for java.util and java ...
  • 添加 到struts.xml完成了这项工作。 如果有任何可能的副作用,请告诉我 Adding to struts.xml did the job. If there are any possible side-effects, please let me know
  • Locale.setDefault是一个全局的东西。 如果您有两个用户需要使用不能解决的不同语言环境。 您应该将语言环境放在HttpServletRequest.getSession() 。 在我们完成全局setDefault之后,它甚至切换了应用程序服务器的语言和日志记录。 The Locale.setDefault is a global thing. If you have two users that need to use differnt locales that won't work out. ...
  • 英国的ISO 3166双字母缩写不是UK ,正确的ID是GB 。 UK是出于兼容性原因(过去犯了一个错误)。 我确实寻找其他的exeptions但没有找到任何,所以现在我只处理特殊情况。 Locale loc = new Locale("en","UK"); // test code if(loc.getCountry().equals("UK")){ loc = new Locale(loc.getLanguage(), "GB"); } Currency cur = Currency. ...
  • 格式如“en_us”或“en_gb”具有“语言代码”_“国家代码” Locale对象包含国家代码和语言代码。 所以你可以使用下面的代码格式化你自己的代码。 String cCode = Locale.getDefault().getCountry(); String lCode = Locale.getDefault().getLanguage(); String code = lCode+"_"+cCode; 要么 您可以使用Locale对象上的toString()方法来获取数据 String code ...
  • 语言环境必须安装在您的计算机上。 在Linux或Mac上,您可以通过执行“locale -a”来获取已安装的语言环境。 Windows有点笨拙,我不认为UTF-8后缀可用。 以下是Windows区域设置的列表。 你应该使用语言字符串。 https://msdn.microsoft.com/en-us/library/39cwe7zf(v=vs.140).aspx 在你的情况下,这将是'我们'。 The locale must be installed on your computer. On Linux o ...
  • Locale.ITALIAN只设置意大利语,国家未指定。 Locale.ITALY将意大利语设置为语言,将意大利设置为国家/地区。 它取决于使用Locale的类如何解释这个组合。 例如,DateFormat API表示要格式化不同Locale的日期,请在调用getDateInstance()时指定它。 但它没有说明语言和国家将如何被解释。 根据我的经验,DateFormat(以及除ResourceBundle之外的其他JDK类)仅使用语言部分而忽略country。 也就是说,您可以为it_IT或it_US或 ...
  • 我可以通过在/content/geometrixx/en/jcr:content节点中添加jcr:language属性来重现您的问题,如下图所示,这会产生以下错误。 27.01.2017 14:38:46.640 WARN [0:0:0:0:0:0:0:1 [1485549526613] GET /content/geometrixx/en.html HTTP / 1.1] com.day.cq.wcm.core .impl.PageImpl存储在/ content / geometrixx / en中的无 ...
  • 现在这已成为一个常见问题,应该成为PyGTK常见问题解答。 例如,请参阅此PyGTK 错误报告 简而言之,您缺少许多细节。 例如: 1)从Python 2.4开始,在Windows上,为os.environ分配值只会更改Python管理的环境变量的副本,不再对C库维护的副本产生任何影响(Python的msvcr90,各种GTK +的msvcrt)相关的dll)。 2)一旦你处理了上述内容,你还需要特别注意配置libintl。 这意味着你需要bindtextdomain()和bind_textdomain_c ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)