我试图按照本教程来启用远程访问MySQL。问题是,my.cnf文件应该放在哪里?我使用的是Mac OS X Lion。
当前回答
这些东西对我都没用。我正在使用当前的dmg安装mysql社区服务器。ps显示my.cnf中所有最关键的参数通常都是在命令行上传递的,我不知道这是从哪里来的。在对我的盒子进行全文搜索后,我发现它在:
/ Library / LaunchDaemons / com . oracle, mysql oss。mysqld plist。
你可以在这里修改它们,也可以把它们拿出来这样它就会尊重你在my。cnf里的那些,不管你放在哪里。
享受吧!
在该文件中找到的文件信息示例:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key> <string>com.oracle.oss.mysql.mysqld</string>
<key>ProcessType</key> <string>Interactive</string>
<key>Disabled</key> <false/>
<key>RunAtLoad</key> <true/>
<key>KeepAlive</key> <true/>
<key>SessionCreate</key> <true/>
<key>LaunchOnlyOnce</key> <false/>
<key>UserName</key> <string>_mysql</string>
<key>GroupName</key> <string>_mysql</string>
<key>ExitTimeOut</key> <integer>600</integer>
<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>--keyring-file-data=/usr/local/mysql/keyring/keyring</string>
<string>--early-plugin-load=keyring_file=keyring_file.so</string>
</array>
<key>WorkingDirectory</key> <string>/usr/local/mysql</string>
</dict>
</plist>
其他回答
在MAC OS上,一个快速的方法是:
sudo find /usr/ -type f -iname "*my.cnf*"
or
brew list mysql@5.7 |grep -i my.cnf
问候
它通常应该在MAC上的/usr/local/etc下,如果你找不到它,你可以创建一个
阅读文档!
您所使用的版本的MySQL文档将有所帮助。 它通常被描述为选项文件或MySQL配置文件。 文档中有这些文件的位置,以及其他重要信息,如位置和配置文件必须看起来像什么小例子。
MySQL版本8
MySQL 5.7版本
MySQL 5.6版本
MySQL 5.5版本
MySQL 5.6日文
重要提示:
在Unix平台上,MySQL忽略全局可写的配置文件。 这是有意为之的安全措施。
换句话说,如果你在配置文件上设置了错误的权限,就不会加载。
一个配置文件的初始设置权限示例:
RIZZOMBP$ ls -lah /etc/my.cnf
-rw-r--r-- 1 myusername wheel 0B Feb 25 20:40 /etc/my.cnf
注意:
可以在选项文件中使用!include指令来包含其他选项文件,并使用!includedir来搜索特定目录中的选项文件..... ...MySQL不保证目录中选项文件被读取的顺序… 在Unix操作系统上使用!includedir指令找到并包含的任何文件的文件名必须以.cnf结尾。在Windows上,这个指令检查扩展名为.ini或.cnf的文件。
如何找到你的配置或日志文件等位置的例子:
SQL
这将不会显示配置文件,但将帮助您定位安装文件/文件夹。
MySQL版本5.7 & 8+
SELECT * FROM PERFORMANCE_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_VALUE LIKE '%\/%';
MySQL版本<= 5.6
SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_VALUE LIKE '%\/%';
壳牌公司-终端
RIZZOMBP$ mysql --help | grep "Default options" -A 1
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
以上命令归功于:Erwin Mayer来自ServerFault
RIZZOMBP$ mysqld --verbose --help | grep '/my.cnf' -B 1
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
OR
RIZZOMBP$ ps aux | grep -i mysqld | grep -v $USER
_mysql 106 0.4 2.5 4232336 422112 ?? Ss 7:01PM 0:57.12
/usr/local/mysql/bin/mysqld
--user=_mysql
--basedir=/usr/local/mysql
--datadir=/usr/local/mysql/data
--plugin-dir=/usr/local/mysql/lib/plugin
--log-error=/usr/local/mysql/data/mysqld.local.err
--pid-file=/usr/local/mysql/data/mysqld.local.pid
--keyring-file-data=/usr/local/mysql/keyring/keyring
--early-plugin-load=keyring_file=keyring_file.so
示例文件
如果您需要详细的参考样本my.cnf:
https://gist.github.com/search?utf8=%E2%9C%93&q=my.cnf+mysql&ref=searchresults https://www.linode.com/community/questions/5749/mysql-sample-config-files https://www.fromdual.com/mysql-configuration-file-sample
没有归属/关联的URL
我的系统:
RIZZOMBP$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.14.3
BuildVersion: 18D109
RIZZOMBP$ mysql -V
mysql Ver 8.0.15 for macos10.14 on x86_64 (MySQL Community Server - GPL)
RIZZOMBP$ mysqld -V
/usr/local/mysql-8.0.15-macos10.14-x86_64/bin/mysqld
Ver 8.0.15 for macos10.14 on x86_64 (MySQL Community Server - GPL)
我正在运行MacOS Mojave(10.14.6),为了让MySQL识别我的配置文件,我必须将它放在/usr/local/ MySQL -5.7.26-macos10.14-x86_64/etc/my.cnf中。我也有一个符号链接指向它从/usr/local/@mysql/etc/my.cnf。
我试图关闭sql_mode=only_full_group_by,在配置文件中设置该选项是在会话之间保持该设置的唯一方法。配置文件的内容如下:
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION
我正在使用MySQL的本机安装,而不是Homebrew设置。
MySQL 5.7 on Mac OS X El Capitan: /usr/local/mysql/etc/my.cnf
从/usr/local/mysql/support-files/my-default.cnf拷贝default conf文件
推荐文章
- 如何关闭mysql密码验证?
- 访问限制:'Application'类型不是API(必需库rt.jar的限制)
- 为什么在Mac OS X v10.9 (Mavericks)的终端中apt-get功能不起作用?
- MySQL区分大小写查询
- 获得PostgreSQL数据库中当前连接数的正确查询
- MySQL数据库表中的最大记录数
- 原则-如何打印出真正的sql,而不仅仅是准备好的语句?
- PHP/MySQL插入一行然后获取id
- 从现有模式生成表关系图(SQL Server)
- “你有邮件”的消息在终端,os X
- HyperLogLog算法是如何工作的?
- 数据库和模式的区别
- 如何从命令行通过mysql运行一个查询?
- Mac OS X中的环境变量
- 如何从命令行在windows中找到mysql数据目录