在 Ubuntu (20.04) VPS 上運行 MySQL (8.0) 數據庫。我當前的目標是嘗試通過 Python 腳本將 .CSV 文件自動加載到表格中。該腳本在理論上是正確的并且應該可以工作,它能夠將數據從 CSV 處理到表中。dbupdate.py:import mysql.connectorimport osimport stringdb = mysql.connector.connect ( host="localhost", user="root", passwd="********", db="Rack_Info")sqlLoadData = "LOAD DATA LOCAL INFILE '/home/OSA_ADVA_Dashboard/Processed_CSV/DownloadedCSV.csv' INTO TABLE BerT FIELDS TERMINATED BY ',' ENCLOSED BY '*' IGNORE 1 LINES;"try: curs = db.cursor() curs.execute(sqlLoadData) db.commit() print ("SQL execution complete") resultSet = curs.fetchall()except IOError: print ("Error incurred: ") db.rollback() db.close()print ("Data loading complete.\n")我查閱了官方文檔并在服務器和客戶端上啟用了 local_infile,配置了 my.cnf 和 SQL。my.cnf 文件:## The MySQL database server configuration file.## You can copy this to one of:# - "/etc/mysql/my.cnf" to set global options,# - "~/.my.cnf" to set user-specific options.## One can use all long options that the program supports.# Run program with --help to get a list of available options and with# --print-defaults to see which it would actually understand and use.## For explanations see# http://dev.mysql.com/doc/mysql/en/server-system-variables.html## * IMPORTANT: Additional settings that can override those from this file!# The files must end with '.cnf', otherwise they'll be ignored.#!includedir /etc/mysql/conf.d/!includedir /etc/mysql/mysql.conf.d/[client]local_infile=1[mysql]local_infile=1[mysqld]local_infile=1我已經重新啟動了 php 和 MySQL 服務,但都無濟于事,服務器也是如此。不知所措。任何幫助將非常感激。
2 回答

幕布斯6054654
TA貢獻1876條經驗 獲得超7個贊
我調查了 php.ini 文件并取消了加載數據行的注釋,但仍然沒有。
結果是 mysqld 的變量之一 secure_file_priv 指向一個空/默認目錄。我所要做的就是將目錄更改為我的文件所在的位置?,F在都在工作。
添加回答
舉報
0/150
提交
取消