国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

mysql secure-file-priv選項問題的解決方法

2020-03-22 17:29:11
字體:
來源:轉載
供稿:網友
mysql可使用 into outfile 參數把表中數據導出到csv,例如可用以下命令把user表的數據導出到user.csv

select * from user into outfile /tmp/user.csv fields terminated by , optionally enclosed by lines terminated by /r/n 

執行后,user表的數據會導出到/tmp/user.csv。

參數說明:

into outfile ‘導出的目錄和文件名’
指定導出的目錄和文件名

fields terminated by ‘字段間分隔符’
定義字段間的分隔符

optionally enclosed by ‘字段包圍符’
定義包圍字段的字符(數值型字段無效)

lines terminated by ‘行間分隔符’
定義每行的分隔符

問題分析

以上命令在mysql5.6下運行沒有問題,但在mysql5.7下運行則出現了以下錯誤。

ERROR 1290 (HY000): The html' target='_blank'>MySQL server is running with the --secure-file-priv option so it cannot execute this statement


查看官方文檔,secure_file_priv參數用于限制LOAD DATA, SELECT …OUTFILE, LOAD_FILE()傳到哪個指定目錄。

secure_file_priv 為 NULL 時,表示限制mysqld不允許導入或導出。

secure_file_priv 為 /tmp 時,表示限制mysqld只能在/tmp目錄中執行導入導出,其他目錄不能執行。

secure_file_priv 沒有值時,表示不限制mysqld在任意目錄的導入導出。


查看 secure_file_priv 的值,默認為NULL,表示限制不能導入導出。

mysql show global variables like %secure_file_priv% +------------------+-------+| Variable_name | Value |+------------------+-------+| secure_file_priv | NULL |+------------------+-------+1 row in set (0.00 sec)

因為 secure_file_priv 參數是只讀參數,不能使用set global命令修改。

mysql set global secure_file_priv= ERROR 1238 (HY000): Variable secure_file_priv is a read only variable
解決方法

打開my.cnf 或 my.ini,加入以下語句后重啟mysql。

secure_file_priv= 

查看secure_file_priv修改后的值

mysql show global variables like %secure_file_priv% +------------------+-------+| Variable_name | Value |+------------------+-------+| secure_file_priv | |+------------------+-------+1 row in set (0.00 sec)

修改后再次執行,成功導出。

mysql select * from user into outfile /tmp/user.csv fields terminated by , optionally enclosed by lines terminated by /r/n Query OK, 15 rows affected (0.00 sec)

mysql可使用 into outfile 參數把表中數據導出到csv,例如可用以下命令把user表的數據導出到user.csv

select * from user into outfile /tmp/user.csv fields terminated by , optionally enclosed by lines terminated by /r/n 

執行后,user表的數據會導出到/tmp/user.csv。

本文講解了mysql5.7導出數據提示--secure-file-priv選項問題的解決方法,更多相關內容請關注php 。

相關推薦:

php 利用debug_backtrace方法跟蹤代碼調用

mysql在終端執行sql并把結果寫入文件的方法

php 基于redis使用令牌桶算法實現流量控制

以上就是mysql secure-file-priv選項問題的解決方法的詳細內容,PHP教程

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 德州市| 内丘县| 塘沽区| 沙湾县| 灌南县| 玉田县| 湘阴县| 广饶县| 周至县| 昭苏县| 广河县| 宁明县| 永寿县| 山阴县| 宜黄县| 苏尼特右旗| 庐江县| 北京市| 株洲市| 应用必备| 历史| 松江区| 西乌| 兴城市| 灵璧县| 康平县| 赤水市| 志丹县| 太和县| 修武县| 岳西县| 饶河县| 垣曲县| 尼木县| 镇平县| 鹤庆县| 琼中| 讷河市| 河曲县| 盘锦市| 大荔县|