您好,登錄后才能下訂單哦!
mysql 默認對導出的目錄有權限限制,也就是說使用命令行進行導出的時候,需要指定目錄進行操作;
mysql> select * from t1 into outfile '/tmp/t1_mysql.csv' fields terminated by ",";
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
解決方法:
1. 查詢mysql 的secure_file_priv 值配置的是什么
[mysqld]
secure-file-priv=/var/lib/mysql
[root@localhost ~]# systemctl restart mysqld
[root@localhost ~]# mysql -u root
2. 使用 into outfile 開始導出:因為secure_file_priv配置的關系,所以必須導出到 /var/lib/mysql/目錄下
mysql> select * from t1 into outfile '/var/lib/mysql/t1_mysql.csv' fields terminated by "," OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n';
3. 關鍵字解釋:因為導出的數據會出現一些亂碼或者特殊字符,所以使用以上關鍵字進行轉義
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY ' " ' LINES TERMINATED BY '\n';
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。