Pet*_*ius 4 mysql configuration mac-os-x
我找不到在哪里设置secure-file-priv。我收到这条消息:
1290 - MySQL 服务器正在使用 --secure-file-priv 选项运行,因此它无法执行此语句
运行此语句时:
SELECT COLUMN_NAME, data_type FROM tabledefs INTO OUTFILE 'xpeter'
Run Code Online (Sandbox Code Playgroud)
如果我删除OUTFILE 'xpeter' 它就可以了。 OUTFILE '/tmp/xpeter也不起作用。
我尝试添加--secure-file-priv="/tmp",没有变化。变量保持为 NULL:
$bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" --secure-file-priv="/tmp" $other_args >/dev/null &
/usr/local/mysql/bin/mysqld --verbose --help | grep secure-file
--secure-file-priv=name
secure-file-priv NULL
Run Code Online (Sandbox Code Playgroud)
没有my.cnf文件。我遍历整个文件系统,寻找任何*.cnf文件。找不到除:./mysql-5.7.17-macos10.12-x86_64/data/auto.cnf和之外的任何其他内容./mysql-5.7.17-macos10.12-x86_64/support-files/my-default.cnf。线路$bindir/mysqld... 在support-files/my-default.cnf.
我重新运行查询,没有OUTFILE 'xpeter',查询 OK,日志文件中没有消息,除了apache2 log. 然后我跑
SELECT COLUMN_NAME, data_type INTO OUTFILE 'xpeter' FROM tabledefs
Run Code Online (Sandbox Code Playgroud)
日志文件中没有错误,仅在 phpmyadmin 中(我从中运行查询语句,以 root 身份登录):与以前相同的消息。
我尝试了etc/my.cnf并且还:
SELECT COLUMN_NAME, data_type FROM tabledefs INTO OUTFILE 'xpeter'
Run Code Online (Sandbox Code Playgroud)
在重新启动后的两种情况下,我仍然不允许写入文件。
我没有更改文件夹所有者。如果我添加--secure-file-priv=/mysql_exp到守护程序并重新启动 MySQL 根本不会运行。
在 mac os x 上 mysql 的启动参数可以通过编辑 .plist 文件来更改
地点:
/Library/LaunchDaemons
com.oracle.oss.mysql.mysqld.plist
Run Code Online (Sandbox Code Playgroud)
使用 Xcode 或例如 BBEdit,并在 ProgramArguments 部分添加行
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>ExitTimeOut</key>
<integer>600</integer>
<key>GroupName</key>
<string>_mysql</string>
<key>KeepAlive</key>
<false/>
<key>Label</key>
<string>com.oracle.oss.mysql.mysqld</string>
<key>LaunchOnlyOnce</key>
<false/>
<key>ProcessType</key>
<string>Interactive</string>
<key>Program</key>
<string>/usr/local/mysql/bin/mysqld</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/mysql/bin/mysqld</string>
<string>--user=_mysql</string>
<string>--basedir=/usr/local/mysql</string>
<string>--datadir=/usr/local/mysql/data</string>
<string>--plugin-dir=/usr/local/mysql/lib/plugin</string>
<string>--log-error=/usr/local/mysql/data/mysqld.local.err</string>
<string>--pid-file=/usr/local/mysql/data/mysqld.local.pid</string>
<string>--secure-file-priv=/mysql_exp</string>
</array>
<key>RunAtLoad</key>
<false/>
<key>SessionCreate</key>
<true/>
<key>UserName</key>
<string>_mysql</string>
<key>WorkingDirectory</key>
<string>/usr/local/mysql</string>
</dict>
</plist>
Run Code Online (Sandbox Code Playgroud)
重新启动 MySQL 并检查:
mysql> show variables like 'secure%';
+------------------+-------------+
| Variable_name | Value |
+------------------+-------------+
| secure_auth | ON |
| secure_file_priv | /mysql_exp/ |
+------------------+-------------+
2 rows in set (0.00 sec)
Run Code Online (Sandbox Code Playgroud)
添加:
如果直接在 /etc/ 中创建 my.cnf 文件,您可以获得相同的结果
sudo nano /etc/my.cnf
Run Code Online (Sandbox Code Playgroud)
您可以从
/usr/local/mysql/support-files/
Run Code Online (Sandbox Code Playgroud)
只是注释注释-“复制/过去”这不是一种方法,即使在您的 Mac 上您也确实根本不需要文件导入/导出,只需使用普通工具,例如:
他们中的任何一个都可以帮助您:
手动文件级导入/导出在需要自动化流程的生产环境中很有用,但现在它是更多的备份方式,主要和正确的 - ETL 脚本和工具。