【问题标题】:make MySQL server has write permissions in the \xampp\tmp folder使 MySQL 服务器在 \xampp\tmp 文件夹中具有写入权限
【发布时间】:2013-05-16 21:02:36
【问题描述】:

如何将Mysql Server中目录\xampp\tmp的权限改为write

因为当我想使用下面的查询创建和写入 csv 文件时,我在 mysql 中遇到此错误消息(无法创建/写入文件 '\tmp\orders.csv'(错误代码:2 ))

查询:

SELECT g.id, g.name, g.date, g.date_mod, g.status, cree_par, modifier_par
FROM glpi_tickets g , (select id, concat(realname , ' ' , firstname)
cree_par from glpi_users ) c, (select id, concat(realname , ' ' ,
firstname) modifier_par from glpi_users) m
where users_id_recipient <> users_id_lastupdater
and users_id_recipient = c.id
and users_id_lastupdater = m.id 
INTO OUTFILE '/tmp/orders.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'

提前谢谢^^

【问题讨论】:

    标签: mysql sql csv


    【解决方案1】:
    1. 为 /xampp/tmp (unix) 设置可写权限:

      sudo chmod 777 /xampp/tmp
      

      窗户:

      1. Right-click the file or folder, click Properties, and then click the Security tab.
      2. Click Advanced, and then click the Owner tab.
      3. Click Edit, and then do one of the following:
         · To change the owner to a user or group that is not listed, click Other users and groups and, in Enter the object name to select (examples), type the name of the user or group, and then click OK.
         · To change the owner to a user or group that is listed, in the Change owner to box, click the new owner.
      4. If you want to take ownership of the contents of the folder, select the Replace owner on sub containers and objects check box.
      5. Click OK, and then click Yes when you receive the following message:
          · You do not have permission to read the contents of directory folder name. Do you want to replace the directory permissions with permissions granting you Full Control?
          · All permissions will be replaced if you click Yes.
      Note folder name is the name of the folder that you want to take ownership of.
      6. Click OK, and then reapply the permissions and security settings that you want for the folder and its contents.
         Additional considerations
          · An administrator can take ownership of any file on the computer.
          · Assigning ownership of a file or a folder might require you to elevate your permissions using User Access Control.
      
    2. 设置正确的OUTFILE路径

      SELECT g.id, g.name, g.date, g.date_mod, g.status, cree_par, modifier_par
      FROM glpi_tickets g , (select id, concat(realname , ' ' , firstname)
      cree_par from glpi_users ) c, (select id, concat(realname , ' ' ,
      firstname) modifier_par from glpi_users) m
      where users_id_recipient <> users_id_lastupdater
      and users_id_recipient = c.id
      and users_id_lastupdater = m.id 
      INTO OUTFILE '/xampp/tmp/orders.csv'
      FIELDS TERMINATED BY ','
      ENCLOSED BY '"'
      LINES TERMINATED BY '\n'
      

    【讨论】:

    • 我正在使用 Windows 7,所以我可以在哪里添加命令 (( sudo chmod 777 /xampp/tmp ))
    • 如果文件已经存在,查询不会覆盖文件,而是显示以下错误消息:#1086 - File 'xampp/tmp/order.csv' already exists any solution ?
    • @YassineEdouiri 出于安全原因,mysql 无法覆盖现有文件。所以在创建表转储之前删除文件。
    • 我现在在 Windows 7 中工作,但我将使用 cron 在 unix 中使用此代码,我将每晚执行此查询,所以请告诉我 unix 中是否有任何代码可以删除在 cron 执行查询之前的文件
    猜你喜欢
    • 2014-11-29
    • 1970-01-01
    • 2014-12-07
    • 2012-05-16
    • 1970-01-01
    • 2016-02-07
    • 2011-08-21
    • 1970-01-01
    • 2013-10-19
    相关资源
    最近更新 更多