mysqldump(--tab)參數使用


1.嘗試導出整個庫
[root@localhost data]# mysqldump --set-gtid-purged=OFF --tab=/tmp/data db_hxl -u root -pmysql
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='0b23e9fb-0ef2-11e9-8450-525400f3712a:1-32';
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@localhost data]#


[root@localhost data]# mysqldump --set-gtid-purged=OFF --tab=/tmp/data db_hxl -u root -pmysql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
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'

secure-file-priv的值有三種情況:
secure_file_prive=null    ––限制mysqld 不允許導入導出
secure_file_priv=/path/   --限制mysqld的導入導出只能發生在默認的/path/目錄下
secure_file_priv=''       --不對mysqld 的導入 導出做限制

2.修改初始化參數加入如下項
secure_file_priv=''

3.重啟動
[root@localhost ~]# mysqladmin -h localhost -uroot -pmysql shutdown
/opt/mysql5730/bin/mysqld --defaults-file=/opt/mysql5730/conf/my.cnf --user=mysql &



4.繼續報錯
[root@localhost ~]# mysqldump --set-gtid-purged=OFF --tab=/tmp/data db_hxl -u root -pmysql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
mysqldump: Got error: 1: Can't create/write to file '/tmp/data/flush_test.txt' (Errcode: 13 - Permission denied) when executing 'SELECT INTO OUTFILE'

修改目錄權限給mysql用戶
chown -R mysql:mysql /tmp/data

5.再次導出
[root@localhost ~]# mysqldump --set-gtid-purged=OFF --tab=/tmp/data db_hxl -u root -pmysql
mysqldump: [Warning] Using a password on the command line interface can be insecure.

[root@localhost data]# ls -al
total 24
drwxrwxr-x. 2 mysql mysql  176 Nov  9 18:22 .
drwxrwxrwt. 9 root  root   172 Nov  9 18:18 ..
-rw-rw-r--. 1 root  root  2468 Nov  9 18:22 flush_test.sql
-rw-rw-rw-. 1 mysql mysql   82 Nov  9 18:22 flush_test.txt
-rw-rw-r--. 1 root  root  2738 Nov  9 18:22 rule_01.sql
-rw-rw-rw-. 1 mysql mysql    0 Nov  9 18:22 rule_01.txt
-rw-rw-r--. 1 root  root  2485 Nov  9 18:22 tb_index_test.sql
-rw-rw-rw-. 1 mysql mysql    0 Nov  9 18:22 tb_index_test.txt
-rw-rw-r--. 1 root  root  2342 Nov  9 18:22 tb_test.sql
-rw-rw-rw-. 1 mysql mysql   66 Nov  9 18:22 tb_test.txt

可以看到整個庫下的表都導出了

文件說明:
*.sql --創建表的語句
*.txt --文件內容,格式如下
[root@localhost data]# more flush_test.txt
1       name1
2       name2
3       name3
4       name4
5       name5
6       name6
7       name7
8       name8
9       name9
10      name10

 

說明:

導出單個表

mysqldump --set-gtid-purged=OFF --tab=/tmp/data db_hxl flush_test -u root -pmysql

庫名:db_hxl

表名:flush_test

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM