MYSQL secure-file-priv is set to blank, but when running DbDataReader ExecuteReader it behaves as if it is not
P粉794851975
2023-09-02 09:46:46
<p>I have set secure-file-priv="" in my.ini file
If I run the SQL block in MySQL WorkBench, it runs perfectly. </p>
<p>However, when C# actually runs the DbDataReader ExecuteReader, I get an error. <strong>The error tells me that the file doesn't exist, but that's because it appends the default path ("'C:\ProgramData\MySQL\MySQL Server 8.0\Data") to the beginning of the path< /strong>
(The command text is exactly the same as the SQL below)</p>
<p>Valid string examples</p>
<pre class="brush:php;toolbar:false;">LOAD DATA INFILE '_FILEPATH.txt_' INTO TABLE tablename FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' IGNORE 1 LINES (xxx, yyy, zzz)</pre>
<p>Error returned after executing Reader, now with added section</p>
<blockquote>
<p>MySqlException: File '<strong>C:\ProgramData\MySQL\MySQL Server
8.0\Data\DBNAME</strong>_FILEPATH.txt_' not found (OS Error 2 - No such file or directory)</p>
</blockquote>
<p>I don’t want it to contain<strong>“C:\ProgramData\MySQL\MySQL Server
8.0\Data\DBNAME"</strong>, I don't understand why this is happening. Any help would be greatly appreciated!</p>
This is not the answer to my question why it does weird things. However, I solved my problem using a different approach (by executing a Load-Infile).
I chose to use the MySQL client - MySQL Bulk Loader instead of using dbdatareader
So, while I still want to know the answer to my question, this worked for me.