2016-12-01 114 views
0

我遇到類似的問題this,因爲我不能導出到一個文件,但不是重複的,因爲我不問如何解決這個問題,而是找到變量的設置。哪裏可以找到mysql啓動變量的設置位置?

當我運行'mysqld --verbose --help'時,secure-file-priv只設置爲null。它確實如下:

Default options are read from the following files in the given order: 
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf 

但是這似乎並不是實際的配置,而是默認值。我安裝了自制軟件。

我嘗試了很多提供的解決方案,但該變量似乎沒有改變,然後停止,啓動服務器。

我曾嘗試:

  1. 加入 '安全文件私法= 「」'

    /usr/local/Cellar/mysql/5.7.16/mysql-test/suite/ federated/my.cnf /usr/local/Cellar/mysql/5.7.16/mysql-test/suite/ndb_memcache/my.cnf /usr/local/Cellar/mysql/5.7.16/mysql-test/suite/ ndb_ddl/my.cnf /usr/local/Cellar/mysql/5.7.16/mysql-test/suite/ndb_binlog/my.cnf /usr/local/Cellar/mysql/5.7.16/mysql-test/suite/ ndb_big/my.cnf /usr/local /Cellar/mysql/5.7.16/mysql-test/suite/ndb/my.cnf /usr/local/Cellar/mysql/5.7.16/mysql-test/suite/ndbcluster/my.cnf /usr/local /Cellar/mysql/5.7.16/mysql-test/suite/ndb_team/my.cnf /usr/local/Cellar/mysql/5.7.16/mysql-test/suite/ndb_rpl/my.cnf /usr/local /Cellar/mysql/5.7.16/mysql-test/suite/rpl_ndb/my.cnf /usr/local/Cellar/mysql/5.7.16/mysql-test/suite/rpl/my.cnf /usr/local /Cellar/mysql/5.7.16/mysql-test/suite/rpl/extension/bhs/my.cnf /usr/local/Cellar/mysql/5.7.16/mysql-test/include/default_my.cnf

  2. 我已將相同的項目設置爲實際位置。仍然顯示爲NULL。

  3. 我編輯了mysqld.cnf以具有相同的設置。

  4. 我已經編輯com.oracle.oss.mysql.mysqld.plist有,設置(我在Mac上的El Capitain)

我想我的下一個步驟是卸載後重新安裝,但寧願不要。

回答

0

我得到

The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

我能夠通過開放來解決它在/ usr /本地/ mysql /下支撐文件/ MySQL的錯誤。服務器和更改以下行:

$bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" -- $other_args >/dev/null & 
    wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$? 

$bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" --secure-file-priv="" $other_args >/dev/null & 
    wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$? 
0

如果通過MAMP安裝MySQL,配置文件僅僅是局部點文件的位置:

~/.my.cnf 

爲通過MAMP安裝的MySQL(在Mac上)啓用文件讀/寫功能:

  1. 開放 「甲基苯丙胺」 使用聚光燈
  2. 點擊 「停止服務器」
  3. 編輯〜/ .my.cnf(使用vi或你喜歡的編輯器),並以下線:

    $ VI〜 /.my.cnf

[mysqld_safe] 
[mysqld] 
secure_file_priv="/Users/russian_spy/" 
  • 點擊 「開始服務器」(單位爲毫安窗口)
  • 現在,檢查是否正常工作:

    一個。啓動mysql(默認MAMP用戶是root,密碼也是root)

    $ /Applications/MAMP/Library/bin/mysql -u root -p 
    

    b。在mysql中查看白名單路徑

    mysql> SELECT @@GLOBAL.secure_file_priv; 
    +---------------------------+ 
    | @@GLOBAL.secure_file_priv | 
    +---------------------------+ 
    | /Users/russian_spy/   | 
    +---------------------------+ 
    1 row in set (0.00 sec) 
    

    c。最後,通過將表train導出爲CSV文件進行測試

    mysql> SELECT * FROM train INTO OUTFILE '/Users/russian_spy/test.csv' FIELDS TERMINATED BY ','; 
    Query OK, 992931 rows affected (1.65 sec) 
    
    mysql> 
    
    相關問題