内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

mysql5.7導(dǎo)出數(shù)據(jù)時(shí)出現(xiàn)--secure-file-priv選項(xiàng)應(yīng)對方法

下文主要給大家?guī)鞰ySQL5.7導(dǎo)出數(shù)據(jù)時(shí)出現(xiàn)--secure-file-priv選項(xiàng)應(yīng)對方法,希望mysql5.7導(dǎo)出數(shù)據(jù)時(shí)出現(xiàn)--secure-file-priv選項(xiàng)應(yīng)對方法能夠帶給大家實(shí)際用處,這也是我編輯這篇文章的主要目的。好了,廢話不多說,大家直接看下文吧。

專業(yè)領(lǐng)域包括網(wǎng)站設(shè)計(jì)制作、成都做網(wǎng)站成都商城網(wǎng)站開發(fā)、微信營銷、系統(tǒng)平臺開發(fā), 與其他網(wǎng)站設(shè)計(jì)及系統(tǒng)開發(fā)公司不同,創(chuàng)新互聯(lián)的整合解決方案結(jié)合了幫做網(wǎng)絡(luò)品牌建設(shè)經(jīng)驗(yàn)和互聯(lián)網(wǎng)整合營銷的理念,并將策略和執(zhí)行緊密結(jié)合,為客戶提供全網(wǎng)互聯(lián)網(wǎng)整合方案。

mysql可使用 into outfile 參數(shù)把表中數(shù)據(jù)導(dǎo)出到csv,例如可用以下命令把user表的數(shù)據(jù)導(dǎo)出到user.csv

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

執(zhí)行后,user表的數(shù)據(jù)會導(dǎo)出到/tmp/user.csv。
參數(shù)說明:

into outfile ‘導(dǎo)出的目錄和文件名’
指定導(dǎo)出的目錄和文件名

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

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

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

mysql5.7導(dǎo)出數(shù)據(jù)時(shí)出現(xiàn)--secure-file-priv選項(xiàng)應(yīng)對方法

以上命令在mysql5.6下運(yùn)行沒有問題,但在mysql5.7下運(yùn)行則出現(xiàn)了以下錯(cuò)誤。

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

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

  • secure_file_priv 為 NULL 時(shí),表示限制mysqld不允許導(dǎo)入或?qū)С觥?/p>

  • secure_file_priv 為 /tmp 時(shí),表示限制mysqld只能在/tmp目錄中執(zhí)行導(dǎo)入導(dǎo)出,其他目錄不能執(zhí)行。

  • secure_file_priv 沒有值時(shí),表示不限制mysqld在任意目錄的導(dǎo)入導(dǎo)出。

查看 secure_file_priv 的值,默認(rèn)為NULL,表示限制不能導(dǎo)入導(dǎo)出。

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

因?yàn)?secure_file_priv 參數(shù)是只讀參數(shù),不能使用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)

修改后再次執(zhí)行,成功導(dǎo)出。

';

執(zhí)行后,user表的數(shù)據(jù)會導(dǎo)出到/tmp/user.csv。
參數(shù)說明:

into outfile ‘導(dǎo)出的目錄和文件名’
指定導(dǎo)出的目錄和文件名

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

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

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

以上命令在mysql5.6下運(yùn)行沒有問題,但在mysql5.7下運(yùn)行則出現(xiàn)了以下錯(cuò)誤。

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

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

  • secure_file_priv 為 NULL 時(shí),表示限制mysqld不允許導(dǎo)入或?qū)С觥?/p>

  • secure_file_priv 為 /tmp 時(shí),表示限制mysqld只能在/tmp目錄中執(zhí)行導(dǎo)入導(dǎo)出,其他目錄不能執(zhí)行。

  • secure_file_priv 沒有值時(shí),表示不限制mysqld在任意目錄的導(dǎo)入導(dǎo)出。

查看 secure_file_priv 的值,默認(rèn)為NULL,表示限制不能導(dǎo)入導(dǎo)出。

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

因?yàn)?secure_file_priv 參數(shù)是只讀參數(shù),不能使用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)

修改后再次執(zhí)行,成功導(dǎo)出。

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)

對于以上關(guān)于mysql5.7導(dǎo)出數(shù)據(jù)時(shí)出現(xiàn)--secure-file-priv選項(xiàng)應(yīng)對方法,大家是不是覺得非常有幫助。如果需要了解更多內(nèi)容,請繼續(xù)關(guān)注我們的行業(yè)資訊,相信你會喜歡上這些內(nèi)容的。

網(wǎng)站欄目:mysql5.7導(dǎo)出數(shù)據(jù)時(shí)出現(xiàn)--secure-file-priv選項(xiàng)應(yīng)對方法
分享路徑:http://www.rwnh.cn/article32/gcgjpc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站維護(hù)、網(wǎng)站改版、定制網(wǎng)站企業(yè)建站、電子商務(wù)、響應(yīng)式網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

小程序開發(fā)
鄂州市| 克拉玛依市| 两当县| 左贡县| 北辰区| 汤原县| 新沂市| 芜湖县| 合作市| 呈贡县| 特克斯县| 江山市| 伊川县| 丰县| 花莲县| 双江| 高平市| 光山县| 襄垣县| 张掖市| 图木舒克市| 扶绥县| 华阴市| 翼城县| 罗江县| 黄山市| 阿图什市| 大埔县| 西昌市| 雷州市| 台南县| 南昌县| 锡林浩特市| 辉县市| 巴林右旗| 阜南县| 万载县| 柘荣县| 靖远县| 扶沟县| 乐业县|