在哪里可以找到设置mysql启动变量的位置?

时间:2016-12-01 15:47:01

标签: mysql configuration

我遇到了与this类似的问题,因为我无法导出到文件,但不是重复,因为我不是在问如何解决这个问题,而是找到变量的设置位置。

当我运行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. 添加' secure-file-priv =""'

    /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上)

  5. 我认为我的下一步是卸载并重新安装,但不愿意。

2 个答案:

答案 0 :(得分:0)

我得到的错误

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

我可以通过打开/usr/local/mysql/support-files/mysql.server并更改以下行来修复它:

$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=$?

答案 1 :(得分:0)

如果你通过MAMP安装MySQL,配置文件就是这里的本地点文件:

~/.my.cnf

为通过MAMP(在Mac上)安装的MySQL启用文件读/写:

  1. 打开" MAMP"使用聚光灯
  2. 点击"停止服务器"
  3. 编辑〜/ .my.cnf(使用vi或您喜欢的编辑器)和以下几行:

    $ vi~ / .my.cnf

  4. [mysqld_safe]
    [mysqld]
    secure_file_priv="/Users/russian_spy/"
    
    1. 点击"启动服务器" (在MAMP窗口中)
    2. 现在检查它是否有效:

      一个。启动mysql(默认MAMP用户是root,密码也是root)

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

      湾在mysql中查看列入白名单的路径

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

      ℃。最后,通过将表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>