我试图按照本教程来启用远程访问MySQL。问题是,my.cnf文件应该放在哪里?我使用的是Mac OS X Lion。
当前回答
通常,在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 因此,如果该文件不存在,就创建一个。
其他回答
将/usr/local/opt/mysql/support-files/my-default.cnf复制为/etc/my.cnf或/etc/mysql/my.cnf,然后重启mysql。
在mysql 5.6.22中,my.cnf的路径为
/usr/local/opt/mysql/my.cnf
如果在Mac M1和MacOS Monterey 12.0.1中使用Homebrew安装MySQL,则位置为/opt/ Homebrew /etc/my.cnf
在Mac OS X Maverick的情况下,当MySQL通过Homebrew安装时,它位于/usr/local/opt/mysql/my.cnf
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.
推荐文章
- 如何配置Mac OS X术语,使git有颜色?
- 什么是分片,为什么它很重要?
- 如何通过查询在MySQL中获得数据库结构?
- MySQL删除表中的所有行,并将ID重置为零
- 在准备语句中使用“like”通配符
- MySQL中的表名是否区分大小写?
- 库未加载:libmysqlclient.16。在OS X 10.6上使用mysql2 gem运行'rails server'时出现dylib错误
- 我如何确定文件编码在OS X?
- 数据库触发器是必要的吗?
- 如何知道MySQL表最近一次更新?
- 使iTerm以与其他操作系统相同的方式翻译“元键”
- 错误:无法在ARM处理器上的Homebrew中安装英特尔默认前缀(/usr/local)
- 在MySQL中的一个查询中更新多个具有不同值的行
- 如果表存在则删除表并创建它,如果不存在则创建它
- 在Mac OS X上哪里安装Android SDK ?