是否有一个MySQL命令来定位my.cnf配置文件,类似于PHP的phpinfo()定位它的PHP .ini?
当前回答
如果你用的是安装了Homebrew的Mac电脑,那就用吧
编译mysql信息
你会看到
$ brew info mysql
mysql: stable 5.6.13 (bottled)
http://dev.mysql.com/doc/refman/5.6/en/
Conflicts with: mariadb, mysql-cluster, percona-server
/usr/local/Cellar/mysql/5.6.13 (9381 files, 354M) *
最后一行是MySQL文档中的INSTALLERDIR
其他回答
mysql --help | grep /my.cnf | xargs ls
会告诉你my.cnf在Mac/Linux上的位置吗
ls: cannot access '/etc/my.cnf': No such file or directory
ls: cannot access '~/.my.cnf': No such file or directory
/etc/mysql/my.cnf
在本例中,它在/etc/mysql/my.cnf中
ls: /etc/my.cnf: No such file or directory
ls: /etc/mysql/my.cnf: No such file or directory
ls: ~/.my.cnf: No such file or directory
/usr/local/etc/my.cnf
在本例中,它位于/usr/local/etc/my.cnf
我不知道你是如何在Linux环境下安装MySQL的,但你检查过吗?
/etc/my.cnf
如果你使用的是Debian/Ubuntu系统,并且已经配备了现代版本的数据库(从5.7以上,mysql 8也适用),找到我发现的实际.cnf文件的最佳方法是:
sudo update-alternatives --config my.cnf
你应该看到如下输出:
There are 3 choices for the alternative my.cnf (providing /etc/mysql/my.cnf).
Selection Path Priority Status
------------------------------------------------------------
0 /etc/mysql/mariadb.cnf 500 auto mode
1 /etc/mysql/mariadb.cnf 500 manual mode
2 /etc/mysql/my.cnf.fallback 100 manual mode
* 3 /etc/mysql/mysql.cnf 300 manual mode
在/etc/mysql/mysql.cnf中有两行值得注意:
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
MySQL会在/etc/ MySQL /conf目录下寻找所有的.cnf文件。/etc/mysql/mysql.conf. D /
调优快乐!
try
mysql --verbose --help | grep -A 1 "Default options"
如果您正在使用MAMP,请访问模板> MySQL (my.cnf) > [version]
如果您正在运行MAMP无窗口,您可能需要使用customize按钮定制工具栏。
推荐文章
- 使用sudo时未找到命令
- MySQL删除表中的所有行,并将ID重置为零
- 当有命令行参数时,如何使用GDB分析程序的核心转储文件?
- 在准备语句中使用“like”通配符
- MySQL中的表名是否区分大小写?
- 库未加载:libmysqlclient.16。在OS X 10.6上使用mysql2 gem运行'rails server'时出现dylib错误
- 如何知道MySQL表最近一次更新?
- 在MySQL中的一个查询中更新多个具有不同值的行
- 如何强制从另一个SSH会话分离屏幕?
- 如果表存在则删除表并创建它,如果不存在则创建它
- 如何将文件指针(file * fp)转换为文件描述符(int fd)?
- MySQL OR与IN性能
- Linux Bash中双&和分号有什么区别?
- 将值从同一表中的一列复制到另一列
- 删除id与其他表不匹配的sql行