【问题标题】:Where to find where mysql startup variables are set?哪里可以找到设置mysql启动变量的地方?
【发布时间】:2016-12-01 15:47:01
【问题描述】:

我遇到了与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 上)

我认为我的下一步是卸载并重新安装,但不希望这样做。

【问题讨论】:

    标签: mysql configuration


    【解决方案1】:

    我遇到的错误

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

    【讨论】:

      【解决方案2】:

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

      ~/.my.cnf
      

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

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

        $ vi ~/.my.cnf

      [mysqld_safe]
      [mysqld]
      secure_file_priv="/Users/russian_spy/"
      
      1. 点击“启动服务器”(在 MAMP 窗口中)

      现在检查它是否有效:

      一个。启动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>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-02-18
        • 2021-08-17
        • 1970-01-01
        • 2023-03-31
        • 1970-01-01
        • 2011-08-15
        相关资源
        最近更新 更多