我试图按照本教程来启用远程访问MySQL。问题是,my.cnf文件应该放在哪里?我使用的是Mac OS X Lion。
当前回答
如果在Mac M1和MacOS Monterey 12.0.1中使用Homebrew安装MySQL,则位置为/opt/ Homebrew /etc/my.cnf
其他回答
/private/etc/my.cnf for Catalina
在mysql 5.6.22中,my.cnf的路径为
/usr/local/opt/mysql/my.cnf
通常,在Unix和类Unix系统上,MySQL/MariaDB程序在以下位置读取配置/启动文件(按指定顺序):
/etc/my.cnf - Global /etc/mysql/my.cnf - Global SYSCONFDIR/my.cnf - Global SYSCONFDIR represents the directory specified with the SYSCONFDIR option to CMake when MySQL was built. By default, this is the etc directory located under the compiled-in installation directory. $MYSQL_HOME/my.cnf - Server-specific (server only) MYSQL_HOME is an environment variable containing the path to the directory in which the server-specific my.cnf file resides. If MYSQL_HOME is not set and you start the server using the mysqld_safe program, mysqld_safe sets it to BASEDIR, the MySQL base installation directory. file specified with --defaults-extra-file=path if any ~/.my.cnf - User-specific ~/.mylogin.cnf - User-specific (clients only)
来源:使用选项文件。
注意:在Unix平台上,MySQL忽略全局可写的配置文件。这是有意为之的安全措施。
此外,在Mac上有一个简单的方法来检查它。
执行命令sudo fs_usage | grep my.cnf 这将实时报告与该文件相关的任何文件系统活动。 在另一个终端,重新启动MySQL/MariaDB,例如: 重启mysql 或者: Brew服务重新启动mariadb 在终端上使用fs_usage,应该显示正确的位置,例如。 15:52:22 access /usr/local/Cellar/mariadb/10.1.14/my.cnf 0.000002 sh 因此,如果该文件不存在,就创建一个。
这些东西对我都没用。我正在使用当前的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>
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数据目录