【发布时间】:2019-08-09 22:02:07
【问题描述】:
目前,我必须:
我想:
- 启动 MySQLWorkBench 8.0
- MySQLWorkBench 自动连接到该数据库,无需我点击它
我每天都需要重新打开 MySQLWorkbench,因此想取消这一步。
【问题讨论】:
标签: mysql macos mysql-workbench
目前,我必须:
我想:
我每天都需要重新打开 MySQLWorkbench,因此想取消这一步。
【问题讨论】:
标签: mysql macos mysql-workbench
我的第一个想法是:如果您经常需要它,请不要关闭它。
但是,如果您愿意从脚本运行 MySQL Workbench,就很容易实现您想要的。例如在终端中打开 /Application 并运行此命令(在 macOS 上):
open -a MySQLWorkbench.app --args --query "Localhost 8.0"
其中“Localhost 8.0”必须更改为您要打开的连接名称。这将打开该服务器的 SQL IDE。您可以将调用放入 shell 脚本并运行它而不是应用程序本身。
使用--help 代替--query 来打印支持的命令列表:
MySQLWorkbench [<options>] [<name of a model file or sql script>]
Options:
--admin <instance> Open a administration tab to the named instance
--configdir <path> Specify configuration directory location, default is platform specific.
-h, --help Show help options
--log-level <level> Valid levels are: error, warning, info, debug1, debug2, debug3
--log-to-stderr Also log to stderr
--migration Open a migration wizard tab
--model <model file> Open the given EER model file
--open Open the given file at startup (deprecated, use script, model etc.)
--query <connection>|<connection string>Open a query tab and ask for connection if nothing is specified.
If named connection is specified it will be opened,
else connection will be created based on the given connection string,
--quit-when-done Quit Workbench when the script is done
--run <code> Execute the given Python code
--run-python <code> Execute Python code from a file
--run-script <file> Execute Python code from a file
--script <sql file> Open the given SQL file in an connection, best in conjunction with a query parameter
--upgrade-mysql-dbs Open a migration wizard tab
-v, --verbose Enable diagnostics output
--version Show Workbench version number and exit
但是,当使用open 命令时,这不会显示任何输出(由于它的工作方式,另请参阅How to get the output of an os x application on the console, or to a file?),但您可以直接运行应用程序二进制文件(而不是如图所示的应用程序包上),像这样:
./MySQLWorkbench.app/Contents/MacOS/MySQLWorkbench --help
【讨论】:
"C:\..\MySQLWorkbench.exe" --query testdb 但是当我添加--script C:\..\23.10.20.sql 或--open C:\..\23.10.20.sql 时,它们不起作用。我只让应用程序连接到数据库。我将它们组合在一起:"C:\..\MySQLWorkbench.exe" --query testdb --script C:\..\23.10.20.sql 这是组合它们的正确方法吗?我在这里问了这个问题,但没有人回答:stackoverflow.com/questions/64595764/…