简体   繁体   English

SQLSTATE [HY000]:一般错误:1 无法创建/写入文件'/var/www/html/new_7alaqa/public/dumpfiles/15869372079790_1036teachernote.txt'

[英]SQLSTATE[HY000]: General error: 1 Can't create/write to file '/var/www/html/new_7alaqa/public/dumpfiles/15869372079790_1036teachernote.txt'

Folder /var/www/html/new_7alaqa/public/dumpfiles/ owned by mysql:mysql and i'm trying to run:文件夹 /var/www/html/new_7alaqa/public/dumpfiles/ 归 mysql:mysql 所有,我正在尝试运行:

$note_file= time().$user_idd."_".$halaqa_idd.$typed."note.txt";
$note_query="select * from notes where is_deleted = 0 and halaqa_id=".$halaqa_idd."  into outfile '/var/www/html/new_7alaqa/public/dumpfiles/$note_file' FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '),\n(';";

DB::select($note_query);

文件夹权限

Edit: from mysql commands: working in /tmp directory and default directory编辑:来自 mysql 命令:在 /tmp 目录和默认目录中工作

select * from users  into outfile '/var/www/html/new_7alaqa/public/dumpfiles/11.txt';
ERROR 1 (HY000): Can't create/write to file '/var/www/html/new_7alaqa/public/dumpfiles/11.txt' (Errcode: 13 - Permission denied)
mysql> select * from users  into outfile '/tmp/11.txt';
Query OK, 1417 rows affected (0.00 sec)

Depending on your server/db/user accounts set up, here are some things to try:根据您设置的服务器/数据库/用户帐户,可以尝试以下操作:

  1. Try changing the owner of dumpfiles to www-data :尝试将dumpfiles的所有者更改为www-data
sudo chown -R www-data:www-data dumpfiles

You can revert by running您可以通过运行恢复

sudo chown -R mysql:mysql dumpfiles
  1. Give FILE permission to your MySQL user.FILE权限授予您的 MySQL 用户。
GRANT FILE ON *.* TO user;
FLUSH PRIVILEGES;

It's important to note that even if you already gave your user all permissions by running GRANT ALL , it doesn't include the FILE permission.请务必注意,即使您已经通过运行GRANT ALL授予用户所有权限,它也不包括FILE权限。

  1. Try escaping the path:尝试 escaping 路径:
$dumpFilePath = addslashes('/var/www/html/new_7alaqa/public/dumpfiles/$note_file');
$note_query="select * from notes where is_deleted = 0 and halaqa_id=".$halaqa_idd."  into outfile '$dumpFilePath' FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '),\n(';";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PDOException:SQLSTATE[HY000]:一般错误:7890 找不到文件 - PDOException : SQLSTATE[HY000]: General error: 7890 Can't find file SQLSTATE [HY000]:一般错误:1030 - SQLSTATE[HY000]: General error: 1030 为什么SQLSTATE [HY000]:一般错误? - Why SQLSTATE[HY000]: General error? SQLSTATE[HY000]: 一般错误: 1005 Can't create table `test`.`members` (errno: 150 “Foreign key constraint is misformed”) - SQLSTATE[HY000]: General error: 1005 Can't create table `test`.`members` (errno: 150 “Foreign key constraint is incorrectly formed”) SQLSTATE [HY000]:一般错误:2053 - SQLSTATE[HY000]: General error: 2053 SQLSTATE [HY000]:一般错误和array(0){} - SQLSTATE[HY000]: General error and array(0){} SQLSTATE [HY000]:一般错误 - SQLSTATE[HY000]: General error 无法删除或加载表mysql“ SQLSTATE [HY000]:常规错误:1021磁盘已满” - can't delete or load the table mysql “SQLSTATE[HY000]: General error: 1021 Disk full” Laravel 5.4:SQLSTATE[HY000]:一般错误:1005 无法创建表“外键约束格式不正确” - Laravel 5.4: SQLSTATE[HY000]: General error: 1005 Can't create table "Foreign key constraint is incorrectly formed" SQLSTATE[HY000]: 一般错误: 1005 Can't create table `school`.`posts` (errno: 150 "Foreign key constraint is wrongly forms") - SQLSTATE[HY000]: General error: 1005 Can't create table `school`.`posts` (errno: 150 "Foreign key constraint is incorrectly formed")
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM