mysqldump --tab产生文本格式备份与mysql启动选项--secure-file-priv的一点渊源
发表于:2024-11-25 作者:千家信息网编辑
千家信息网最后更新 2024年11月25日,1,使用mysqldump --tab可以对数据库产生文本文件格式的备份[root@mygirl ~]# /usr/local/mysql/bin/mysqldump --tab=/root test
千家信息网最后更新 2024年11月25日mysqldump --tab产生文本格式备份与mysql启动选项--secure-file-priv的一点渊源
Enter password:
mysqldump: Got error: 1290: The MySQL server is running with the --secure-file-priv option so it cannot execute this statement when executing 'SELECT INTO OUTFILE'
[root@mygirl ~]#
180103 20:45:01 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
180103 20:45:01 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.5.58) starting as process 4922 ...
180103 20:45:01 [Note] Plugin 'FEDERATED' is disabled.
--secure-file-priv=name
secure-file-priv NULL
[root@mygirl ~]#
Enter password:
[1] 5335
[root@mygirl ~]# 180103 21:25:57 mysqld_safe Logging to '/usr/local/mysql/data/mygirl.err'.
180103 21:25:57 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
Enter password:
mysqldump: Got error: 1290: The MySQL server is running with the --secure-file-priv option so it cannot execute this statement when executing 'SELECT INTO OUTFILE'
[root@mygirl ~]#
mysql> show variables like '%secure_file%';
+------------------+-------------------------------------------------+
| Variable_name | Value |
+------------------+-------------------------------------------------+
| secure_file_priv | /usr/local/mysql-5.5.58-linux-glibc2.12-x86_64/ |
+------------------+-------------------------------------------------+
1 row in set (0.00 sec)
Enter password:
[root@mygirl ~]#
[1] 5488
[root@mygirl ~]# 180103 21:30:23 mysqld_safe Logging to '/usr/local/mysql/data/mygirl.err'.
180103 21:30:23 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
[root@mygirl ~]#
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| secure_file_priv | |
+------------------+-------+
1 row in set (0.00 sec)
Enter password:
mysqldump: Got error: 1: Can't create/write to file '/root/t_commit.txt' (Errcode: 13) when executing 'SELECT INTO OUTFILE'
[root@mygirl ~]#
Enter password:
[root@mygirl ~]#
[root@mygirl ~]# ll /usr/local/mysql/data/t_*
-rw-r--r--. 1 root root 1311 Jan 3 21:31 /usr/local/mysql/data/t_commit.sql
-rw-rw-rw-. 1 mysql mysql 6 Jan 3 21:31 /usr/local/mysql/data/t_commit.txt
-rw-r--r--. 1 root root 1308 Jan 3 21:31 /usr/local/mysql/data/t_other.sql
-rw-rw-rw-. 1 mysql mysql 0 Jan 3 21:31 /usr/local/mysql/data/t_other.txt
[root@mygirl data]# more t_commit.sql
-- MySQL dump 10.13 Distrib 5.5.58, for linux-glibc2.12 (x86_64)
--
-- Host: localhost Database: test
-- ------------------------------------------------------
-- Server version 5.5.58
/*!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 `t_commit`
--
DROP TABLE IF EXISTS `t_commit`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t_commit` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!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 2018-01-03 21:31:42
[root@mygirl data]#
[root@mygirl data]# more t_commit.txt
1
2
3
1,使用mysqldump --tab可以对数据库产生文本文件格式的备份
[root@mygirl ~]# /usr/local/mysql/bin/mysqldump --tab=/root test -u root -pEnter password:
mysqldump: Got error: 1290: The MySQL server is running with the --secure-file-priv option so it cannot execute this statement when executing 'SELECT INTO OUTFILE'
[root@mygirl ~]#
2,查看--secure-file-priv选项含义
[root@mygirl ~]# /usr/local/mysql/bin/mysqld --verbose --help|grep -i --color secure-file-priv180103 20:45:01 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
180103 20:45:01 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.5.58) starting as process 4922 ...
180103 20:45:01 [Note] Plugin 'FEDERATED' is disabled.
--secure-file-priv=name
secure-file-priv NULL
[root@mygirl ~]#
3,关闭mysql server
[root@mygirl ~]# /usr/local/mysql/bin/mysqladmin shutdown -u root -pEnter password:
4,修正选项--secure-file-priv重启mysql server
[root@mygirl ~]# /usr/local/mysql/bin/mysqld_safe --secure-file-priv=/usr/local/mysql &[1] 5335
[root@mygirl ~]# 180103 21:25:57 mysqld_safe Logging to '/usr/local/mysql/data/mygirl.err'.
180103 21:25:57 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
5,看来选项修改的结果不合理,备份仍旧报错
[root@mygirl ~]# /usr/local/mysql/bin/mysqldump --tab=/root test -u root -pEnter password:
mysqldump: Got error: 1290: The MySQL server is running with the --secure-file-priv option so it cannot execute this statement when executing 'SELECT INTO OUTFILE'
[root@mygirl ~]#
mysql> show variables like '%secure_file%';
+------------------+-------------------------------------------------+
| Variable_name | Value |
+------------------+-------------------------------------------------+
| secure_file_priv | /usr/local/mysql-5.5.58-linux-glibc2.12-x86_64/ |
+------------------+-------------------------------------------------+
1 row in set (0.00 sec)
6,再次关闭mysql server
[root@mygirl ~]# /usr/local/mysql/bin/mysqladmin shutdown -u root -pEnter password:
[root@mygirl ~]#
7,再次修改--secure-file-priv,即配置为空,可以产生文本格式的备份
[root@mygirl ~]# /usr/local/mysql/bin/mysqld_safe --secure-file-priv= &[1] 5488
[root@mygirl ~]# 180103 21:30:23 mysqld_safe Logging to '/usr/local/mysql/data/mygirl.err'.
180103 21:30:23 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
[root@mygirl ~]#
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| secure_file_priv | |
+------------------+-------+
1 row in set (0.00 sec)
8,--tab只能指定所有权为mysql用户及组的目录,否则报错
[root@mygirl ~]# /usr/local/mysql/bin/mysqldump --tab=/root test -u root -pEnter password:
mysqldump: Got error: 1: Can't create/write to file '/root/t_commit.txt' (Errcode: 13) when executing 'SELECT INTO OUTFILE'
[root@mygirl ~]#
9,文本格式的备份在--tab指定的目录,并且数据库中每个表皆有2个不同扩展名的文件,各为.sql and .txt
[root@mygirl ~]# /usr/local/mysql/bin/mysqldump --tab=/usr/local/mysql/data test -u root -pEnter password:
[root@mygirl ~]#
[root@mygirl ~]# ll /usr/local/mysql/data/t_*
-rw-r--r--. 1 root root 1311 Jan 3 21:31 /usr/local/mysql/data/t_commit.sql
-rw-rw-rw-. 1 mysql mysql 6 Jan 3 21:31 /usr/local/mysql/data/t_commit.txt
-rw-r--r--. 1 root root 1308 Jan 3 21:31 /usr/local/mysql/data/t_other.sql
-rw-rw-rw-. 1 mysql mysql 0 Jan 3 21:31 /usr/local/mysql/data/t_other.txt
10,可见上述.sql和.txt文件分别对应每个表的定义表的脚本及表的实质数据
[root@mygirl ~]# cd /usr/local/mysql/data[root@mygirl data]# more t_commit.sql
-- MySQL dump 10.13 Distrib 5.5.58, for linux-glibc2.12 (x86_64)
--
-- Host: localhost Database: test
-- ------------------------------------------------------
-- Server version 5.5.58
/*!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 `t_commit`
--
DROP TABLE IF EXISTS `t_commit`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t_commit` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!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 2018-01-03 21:31:42
[root@mygirl data]#
[root@mygirl data]# more t_commit.txt
1
2
3
备份
文本
格式
数据
文件
再次
数据库
目录
不合理
不同
含义
实质
所有权
扩展名
用户
结果
脚本
配置
渊源
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
部队网络安全手绘海报图片
山西网络技术转让哪个好
层次模型 数据库
网络安全工程师定向培训
崇明区口碑好的软件开发不二之选
网络安全设计课程设计
我国数据库发展我们能做什么
鹰潭嵌入式软件开发招聘
spss数据库怎么导入
忠县网络安全审计系统咨询公司
qr解析服务器维护
steam服务器崩了2022
组织开展网络安全自查情况
跨库写入数据库
搭建linux服务器教程学习
北京市网络安全周
数据库字段赋值
中国烟草需要网络安全吗
泰安GIS软件开发招聘
nas流媒体转发服务器
优炫数据库金融行业
软件开发公司业务部门的组成
亿清网络技术有限公司 电话
ps软件开发意义
中二网络技术安全考试试卷
网络安全软件学习励志
中国科学院生物文献数据库
网络技术咋学
dayz架设好服务器怎么进去
珠海虚拟化服务器