我们如何解决 MySQL 错误“ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement”在导入或导出数据时
MySQL抛出此错误的原因有两个,要么在--secure--file--priv变量下未指定目录,要么在导入或导出数据时在查询中提供了错误的路径。要解决此错误,我们必须通过以下查询检查–secure-file-priv变量的值-
mysql> Select @@global.secure_file_priv; +---------------------------+ | @@global.secure_file_priv | +---------------------------+ | C:\mysql\bin\mysql-files\ | +---------------------------+ 1 row in set (0.00 sec)
我们可以看到,secure_file_priv变量下有路径,导出数据时所有的文件都会创建在这个目录下。
但是,如果上面的命令显示NULL作为结果,则表示没有指定路径,我们需要my.ini在导出数据之前指定文件中的路径。假设如果我们将secure_file_priv=mysql-files/写入我们的my.ini文件中,那么secure_file_priv将具有上述路径作为其值。然后所有文件都将在此目录下创建。