MySQL 实用程序 - ~/.my.cnf 选项文件
我正在尝试使用 2 个 mysql 实用程序,mysqldiff 和 mysqldbcompare,并希望避免将密码放在命令行上
I am trying to use 2 of the mysql utilities, mysqldiff and mysqldbcompare and want to avoid putting my password on the command line
是否可以使用选项文件为我的数据库连接指定密码,以防止我必须指定密码?
Is it possible to use an option file to specify the password for my DB connection to prevent me having to specify the password?
这是我目前拥有的那种命令...
This is the sort of command that I currently have...
/usr/share/mysql-workbench/python/mysqldiff --server1=root@localhost --server2=root@localhost --difftype=sql db1:db2
我在 ~/.my.cnf 也有一个文件,它具有600"权限并包含以下内容..
I also have a file at ~/.my.cnf that has "600" permissions and contains the following..
[client]
user=root
password=mypassword
当我通过命令行连接到 MySQL 时,它会在我的选项文件中获取详细信息,但 mysql 实用程序不会:-/
When I connect via the command line to MySQL it picks up the details in my option file but the mysql utilities don't :-/
推荐答案
试试这个 -
[client]
user=root
password="pass"
[mysql]
user=root
password="pass"
[mysqldump]
user=root
password="pass"
[mysqldiff]
user=root
password="pass"
.my.cnf 的位置:~/.my.cnf
Location for .my.cnf: ~/.my.cnf
请参考手册页使用选项文件一个>
相关文章