我试图按照本教程来启用远程访问MySQL。问题是,my.cnf文件应该放在哪里?我使用的是Mac OS X Lion。


当前回答

在mysql 5.6.22中,my.cnf的路径为

/usr/local/opt/mysql/my.cnf 

其他回答

我在macOS Sierra上安装了MySql 5.7.12

支持文件位于

/usr/local/opt/mysql/support-files

只要将my-default.cnf复制到/etc/my.cnf或/etc/mysql/my.cnf,重新启动时配置就会被拾取。

/private/etc/my.cnf for Catalina

In my case, the file did not exist. In MySQL Workbench I went to OPTIONS FILE and found some default values. I clicked apply. It asked for permission. It then created the my.cnf file under /etc. However, it is very important to keep in mind that the first time you click "apply", you do not make any changes to the default configuration. Once the file has been created, you can make changes which will be applied when you click "apply". Otherwise you will not be shown the apply button when you make changes.

这些东西对我都没用。我正在使用当前的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

问候