mysql - MySQL Workbench:启动时自动连接到数据库
问题描述
目前,我必须:
我想:
- 启动 MySQLWorkBench 8.0
- MySQLWorkBench 自动连接到该数据库,无需我点击它
我需要在一天中重新打开 MySQLWorkbench,因此想消除这一步。
解决方案
我的第一个想法是:如果您经常需要它,请不要关闭它。
但是,如果您愿意从脚本运行 MySQL Workbench,则很容易实现您想要的。例如/Application
在终端中打开并运行此命令(在 macOS 上):
open -a MySQLWorkbench.app --args --query "Localhost 8.0"
其中“Localhost 8.0”必须更改为您要打开的连接名称。这将打开该服务器的 SQL IDE。您可以将调用放入 shell 脚本并运行它而不是应用程序本身。
而不是--query
用于--help
打印支持的命令列表:
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
(由于它的工作方式,另请参阅如何在控制台上获取 os x 应用程序的输出,或到文件?),但您可以运行该应用程序直接二进制(而不是上面显示的应用程序包),如下所示:
./MySQLWorkbench.app/Contents/MacOS/MySQLWorkbench --help
推荐阅读
- ag-grid - AG Grid:验证行的更好方法 - valueSetter?
- parallel-processing - GridSearchCv、RandomSearchCV 出现并行错误。适用于单个模型
- sqlite - 使用 SQLite db 在 Azure 中发布 webapp
- ember.js - 如何在 Ember 中测试组件的计算属性?
- javascript - AngularJs - 参数“AppController”不是函数,未定义
- java - 无法在 java 匹配中加载属性-
- android - 意图重定向代码之后如何执行代码?
- graphql - 使用 Prisma 生成的包装器查询节点时包含关系
- r - 使用 R pkgdown 时的 ENOENT
- amazon-web-services - AWS StepFunctions:通过 lambda 使用 AWS-SDK 创建状态机时出错