文章目录
今天在操作数据库的时候遇到了数据库导入导出的问题,具体报错内容如下:
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
我的解决办法:
(1)首先查看 secure-file-priv 的设置情况
在终端进入 MySQL后输入命令show variables like 'secure_file_priv';
secure-file-priv 有三种情况:NULL / ‘path’(设置好的路径) /空。
NULL 表示数据的导入和导出被限制
‘path’ 表示数据的导入和导出都要在这个路径下进行
空 表示数据的导入和导出不受限制
MySQL 中默认情况下 secure-file-priv 的设置为 NULL,如下:
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| secure_file_priv | NULL |
+------------------+-------+
(2)修改 secure-file-priv 的值
正常情况下应该在 my.cnf 文件中进行配置,但是在电脑里找了好多地方都没有my.cnf文件,因此结合网上的一些说法,我在 /etc/ 下面自己新建了 my.cnf 文件,文件中所写内容如下:
# Example MySQL config file for medium systems.
#
# This is for a system with little memory (32M - 64M) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together with
# other programs (such as a web server)
#
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.
# The following options will be passed to all MySQL clients
[client]
default-character-set=utf8
password = "机器的mysql密码"
port = 3306
socket = /tmp/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
character-set-server=