mysqldump: Got error: 1: Can't create/write to file (Errcode: 13 - Permission denied) when execu

问题描述:

[root@mysqlcentos01 evis]# mysqldump -uroot -S /tmp/mysql3306.sock -pevis123 test salary  -T .
mysqldump: [Warning] Using a password on the command line interface can be insecure.
Warning: A partial dump from a server that has GTIDs will by default include the GTIDs of all transactions, even those that changed suppressed parts of the database. If you don't want to restore GTIDs, pass --set-gtid-purged=OFF. To make a complete dump, pass --all-databases --triggers --routines --events. 
SET @MYSQLDUMP_TEMP_LOG_BIN = @@SESSION.SQL_LOG_BIN;
SET @@SESSION.SQL_LOG_BIN= 0;
--
-- GTID state at the beginning of the backup 
--
SET @@GLOBAL.GTID_PURGED='8b3a2bfc-5ff9-11e7-a6aa-080027f004fe:1-138';
mysqldump: Got error: 1: Can't create/write to file '/root/evis/salary.txt' (Errcode: 13 - Permission denied) when executing 'SELECT INTO OUTFILE'
[root@mysqlcentos01 evis]#

这个看报错非常明显是权限问题

但赋权后才发现即使是mysql:mysql 777都会报同样的错误

放在/data/mysql/evis/下赋权mysql:mysql解决问题

[root@mysqlcentos01 data]# cd mysql/evis/

[root@mysqlcentos01 evis]# mysqldump -uroot -S /tmp/mysql3306.sock -pevis123 test salary  -T .
mysqldump: [Warning] Using a password on the command line interface can be insecure.
Warning: A partial dump from a server that has GTIDs will by default include the GTIDs of all transactions, even those that changed suppressed parts of the database. If you don't want to restore GTIDs, pass --set-gtid-purged=OFF. To make a complete dump, pass --all-databases --triggers --routines --events. 
SET @MYSQLDUMP_TEMP_LOG_BIN = @@SESSION.SQL_LOG_BIN;
SET @@SESSION.SQL_LOG_BIN= 0;
--
-- GTID state at the beginning of the backup 
--
SET @@GLOBAL.GTID_PURGED='8b3a2bfc-5ff9-11e7-a6aa-080027f004fe:1-138';
SET @@SESSION.SQL_LOG_BIN = @MYSQLDUMP_TEMP_LOG_BIN;
[root@mysqlcentos01 evis]# ll
total 8
-rw-r--r-- 1 root  root  1348 Aug 21 17:26 salary.sql
-rw-rw-rw- 1 mysql mysql   55 Aug 21 17:26 salary.txt

[root@mysqlcentos01 evis]#

[root@mysqlcentos01 evis]# ll
total 8
-rw-r--r-- 1 root  root  1348 Aug 21 17:26 salary.sql
-rw-rw-rw- 1 mysql mysql   55 Aug 21 17:26 salary.txt
[root@mysqlcentos01 evis]# cat salary.txt 
1 1000.00
2 2000.00
3 3000.00
4 4000.00
5 5000.00
1 \N
[root@mysqlcentos01 evis]# cat salary.sql 
-- MySQL dump 10.13  Distrib 5.7.18, for linux-glibc2.5 (x86_64)
--
-- Host: localhost    Database: test
-- ------------------------------------------------------
-- Server version 5.7.18-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
-- Table structure for table `salary`
--
DROP TABLE IF EXISTS `salary`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `salary` (
  `useid` int(11) DEFAULT NULL,
  `salary` decimal(9,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;


/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;


/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;


-- Dump completed on 2017-08-21 17:26:39
[root@mysqlcentos01 evis]# 


你可能感兴趣的:(MySql)