日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > 数据库 >内容正文

数据库

mysql导入数据报错ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it

發(fā)布時(shí)間:2023/12/15 数据库 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql导入数据报错ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

參考:https://blog.csdn.net/u011677147/article/details/64129606

參考:http://blog.itpub.net/31015730/viewspace-2152273/

導(dǎo)入數(shù)據(jù)報(bào)錯(cuò)

mysql> LOAD DATA INFILE '/tmp/1.txt' INTO TABLE hr.employees; ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

原因:安裝MySQL的時(shí)候限制了導(dǎo)入與導(dǎo)出的目錄權(quán)限

查看secure_file_priv該變量的設(shè)置:

mysql> SHOW GLOBAL VARIABLES LIKE '%secure%'; +--------------------------+-----------------------+ | Variable_name | Value | +--------------------------+-----------------------+ | require_secure_transport | OFF | | secure_auth | ON | | secure_file_priv | /var/lib/mysql-files/ | +--------------------------+-----------------------+ 3 rows in set (0.01 sec)

secure_file_priv的值為/var/lib/mysql-files/,即導(dǎo)入導(dǎo)出的目錄必須是/var/lib/mysql-files/

解決辦法一:

臨時(shí)修改這個(gè)值

mysql> SET GLOBAL secure_file_priv=''; ERROR 1238 (HY000): Variable 'secure_file_priv' is a read only variable

解決辦法二:

把要導(dǎo)入的文件復(fù)制到/var/lib/mysql-files/目錄下,然后導(dǎo)入,顯然麻煩

[root@nfs ~]# cp /tmp/1.txt /var/lib/mysql-files/ [root@nfs ~]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. mysql> LOAD DATA INFILE '/var/lib/mysql-files/1.txt' INTO TABLE hr.employees; Query OK, 1 row affected (0.01 sec) Records: 1 Deleted: 0 Skipped: 0 Warnings: 0

解決辦法三:

修改my.ini配置文件

選項(xiàng)說(shuō)明:

secure_file_prive=null???限制mysqld 不允許導(dǎo)入導(dǎo)出

secure_file_priv=/var/lib/mysql-files/???限制mysqld的導(dǎo)入導(dǎo)出只能發(fā)生在/var/lib/mysql-files/目錄下

secure_file_priv=''?????不對(duì)mysqld的導(dǎo)入導(dǎo)出做限制

[root@nfs ~]# vim /etc/my.cnf [root@nfs ~]# egrep -v "^$|#" /etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock symbolic-links=0 log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid secure_file_priv=''

重啟mysql

[root@nfs ~]# systemctl restart mysqld

就可以了:

[root@nfs ~]# cat /tmp/2.txt 008,berry,john,example@qq.com,010222567,admin,20110302 [root@nfs ~]# mysql -uroot -p Enter password: mysql> LOAD DATA INFILE '/tmp/2.txt' INTO TABLE hr.employees FIELDS TERMINATED BY ','; Query OK, 1 row affected (0.15 sec) Records: 1 Deleted: 0 Skipped: 0 Warnings: 0 mysql> select * from hr.employees; +-------------+------------+-----------+-------------------+------------+------------+------------+ | employee_id | first_name | last_name | e_mail | telephone | department | hire_date | +-------------+------------+-----------+-------------------+------------+------------+------------+ | 1 | eric | william | test@gmail.com | 1065103488 | tech | 2011-01-13 | | 2 | quan | hope | NULL | NULL | NULL | NULL | | 3 | wei | shen | NULL | NULL | NULL | NULL | | 4 | boyi | liu | NULL | NULL | NULL | NULL | | 5 | lucy | black | NULL | NULL | NULL | NULL | | 6 | tangsh | quan | test@gmail.com | 1065103488 | tech | 2012-01-13 | | 7 | ellis | jim | example@gmail.com | 1065103488 | sale | 2013-01-02 | | 8 | berry | john | example@qq.com | 10222567 | admin | 2011-03-02 | +-------------+------------+-----------+-------------------+------------+------------+------------+ 8 rows in set (0.00 sec)

再次查看secure_file_priv的值

mysql> show global variables like "%secure%"; +--------------------------+-------+ | Variable_name | Value | +--------------------------+-------+ | require_secure_transport | OFF | | secure_auth | ON | | secure_file_priv | | +--------------------------+-------+ 3 rows in set (0.01 sec)

?

總結(jié)

以上是生活随笔為你收集整理的mysql导入数据报错ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。