今天有個(gè)網(wǎng)友問,在用mysqldump備份時(shí)候遇到1290的錯(cuò)誤 下面是是我模擬他的報(bào)錯(cuò)信息 [root@potato Desktop]# mysqldump -uroot -proot -S /tmp/mysql.sock --tab=/data/mysql/mytest_3306/data/backup lala 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'
可以很清楚地從提示看到是因?yàn)閙ysql服務(wù)啟用了--secure-file-priv,所以才無法執(zhí)行。 那么--secure-file-priv又是什么東東,應(yīng)該如何解決才能是它可以備份呢? --secure-file-priv=name : Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files within specified directory 可以看到secure-file-priv參數(shù)是用來限制LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE()傳到哪個(gè)指定目錄的。 當(dāng)secure_file_priv的值為null ,表示限制mysqld 不允許導(dǎo)入|導(dǎo)出 當(dāng)secure_file_priv的值為/tmp/ ,表示限制mysqld 的導(dǎo)入|導(dǎo)出只能發(fā)生在/tmp/目錄下 當(dāng)secure_file_priv的值沒有具體值時(shí),表示不對(duì)mysqld 的導(dǎo)入|導(dǎo)出做限制
然后再查一下此時(shí)參數(shù)的值 root@localhost:mysql.sock 00:28:30 [(none)]>show global variables like '%secure%'; +------------------+-------+ | Variable_name | Value | +------------------+-------+ | secure_auth | ON | | secure_file_priv | | +------------------+-------+ 2 rows in set (0.00 sec) 已經(jīng)是我們要的結(jié)果 開始進(jìn)行導(dǎo)出 [root@potato Desktop]# mysqldump -uroot -proot -S /tmp/mysql.sock --tab=/data/mysql/mytest_3306/data/backup lala Warning: Using a password on the command line interface can be insecure. 可以看到成功了