MySQL Workbench – specify Server/User/Pass on command line

MySQLmysql-workbench

I am currently testing Privileged Access Management solutions. I have a need to open the MySQL Workbench with a command line that specifies the server name, and user/password of the privileged account that is being used for that session.

In MSFT SQL Server Studio, you can start it with '-S servername -U username -P password' There doesn't seem to be a straightforward way to do this using the MySQL Workbench. There is a '-query' option, but I can't find anything that specifies how to fully start the app with those parameters supplied dynamically.

Can anyone suggest a way to do this with MySQL Workbench?

Best Answer

You can use the query parameter and give it the name of one of the connections you have defined (similar for the admin parameter). This will open a SQL IDE tab with that connection.

Instead of a predefined connection you can also use the usual command line params -h127.0.0.1 -uroot -P3306 in conjunction with the query and admin parameters.

For details how this is parsed look in wb_utils_grt.py (connectionFromString(connstr)).

Update:

The documentation says:

--query [connection|connection_string]: Empty: Open a query tab and prompts for a connection.

Connection: Open a named connection.

Connection_string: Create a connection based on the entered connection string, which should be in the form $USER@$HOST:$PORT.