Creating a Connection from External Parameters in dbForge Studio for MySQL

Creating a Connection from External Parameters in dbForge Studio for MySQL

dbForge Studio for MySQL does not currently support creating or opening connections by passing connection parameters through command-line arguments or Privileged Access Management (PAM) solutions.

The workaround described below allows a connection to be created programmatically by adding the required settings directly to the Windows Registry before launching the application.

Current Limitation

Launching dbForge Studio for MySQL with predefined connection parameters, such as host, port, user name, password, and database, is not supported in the current version of the product.
Info
Support for this functionality is planned for future releases.

Workaround: Creating a Connection Using PowerShell

Connection settings, including the encrypted password, are stored in the Windows Registry under the following key:

HKEY_CURRENT_USER\Software\Devart\dbForge Common Settings\Connections\MySQL

A connection can be created programmatically by populating this registry key before starting dbForge Studio for MySQL.

Step 1. Remove Existing Connections
  1. Open dbForge Studio for MySQL and remove all existing connections from Database Explorer. (If necessary, Export Settings beforehand.)
  2. Close the application after removing the connections.


Step 2. Clean Up the Registry
  1. Open the following registry key: HKEY_CURRENT_USER\Software\Devart\dbForge Common Settings\Connections\MySQL
  2. Make sure it does not contain any subkeys. If subkeys are present, remove them.


Step 3. Run the PowerShell Script

Run the following PowerShell script and provide the required parameters:
  1. host
  2. port
  3. user
  4. password
  5. database

Quote
exmple_code_file.ps1

# Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
$host_name = Read-Host "Please enter a host"
$port = Read-Host "Please enter a port"
$database = Read-Host "Please enter a database"
$user = Read-Host "Please enter a user"
$password = Read-Host "Please enter a password"

# Path to Devart.Shell.Core.dll
$dllPath = "C:\Program Files\Devart\dbForge Studio for MySQL\Devart.Shell.Core.dll"

Add-Type -Path $dllPath
$encryptedPassword = [Devart.Shell.Common.Utils.MiscUtils]::EncodeString($password)
$ConnectionString = "User Id=" + $user + ";Host=" + $host_name + ";Port=" + $port + ";Database=" + $database
$RegConnectionMySQLFolder = "HKCU:\SOFTWARE\Devart\dbForge Common Settings\Connections\MySQL\"
$connection_name = $database + "." + $host_name + ":" + $port
$n = 0

New-Item -Path $RegConnectionMySQLFolder -Name $n
$RegConnectionMySQL_n = $RegConnectionMySQLFolder + $n
New-ItemProperty -Path $RegConnectionMySQL_n -Name "ConnectionString" -Value $ConnectionString -PropertyType "String"
New-ItemProperty -Path $RegConnectionMySQL_n -Name "Database" -Value "59f90733-4d68-4fdf-82a7-f0fcbf5460aa"
New-ItemProperty -Path $RegConnectionMySQL_n -Name "Name" -Value $connection_name
New-ItemProperty -Path $RegConnectionMySQL_n -Name "Password" -Value $encryptedPassword -PropertyType Binary

As a result, dbForge Studio for MySQL should create a connection with a saved password.


Step 4. Launch dbForge Studio for MySQL
  1. Start dbForge Studio for MySQL.
  2. The newly created connection will appear in Database Explorer and can be opened in the usual way.


Step 5. Click Open Connection to connect to the server.

Alternative Approach: Transferring a Connection Between Machines

An existing connection can also be transferred from one machine to another.
  1. Create the connection through the dbForge Studio for MySQL UI on the source machine.
  2. Open the following registry key: HKEY_CURRENT_USER\Software\Devart\dbForge Common Settings\Connections\MySQL
  3. Locate the required connection and export it to a .reg file.
  4. Copy the exported file to the target machine.
  5. Import the registry file by running: reg import file.reg
After the import is completed, the connection becomes available in dbForge Studio for MySQL on the target machine.

    • Related Articles

    • How to Connect to MySQL Server

      In the second article of the series uncovering how to get started with MySQL, we talk about the ways of connecting to MySQL Server. You can connect to MySQL Server using MySQL Client, dbForge Studio for MySQL, and MySQL Workbench. In this article, we ...
    • Timestamps Not in Expected Timezone in dbForge Studio for Oracle

      If you're encountering timestamps that don't match your system's timezone in dbForge Studio for Oracle, this can typically be resolved with a quick configuration update. This issue may arise due to default formatting settings or discrepancies in how ...
    • SSH Host Key Verification Error in dbForge Studio for MySQL

      Attempting to connect to a server over SSH may fail with the following error message: Can't connect to SSH server: The computed hash verification does not correspond to the received. (code 0) The same connection may work successfully in PuTTY or ...
    • Lost Connection to MySQL Server

      A lost connection to a MySQL server is a common issue and, in most cases, is not related to dbForge tools. It typically occurs due to server settings, network interruptions, or long-running queries. Recommended Solution For official guidance on ...
    • How to Install MySQL on Windows Using MySQL Installer

      This article provides a comprehensive walkthrough on how to install MySQL on Windows using the official MySQL Installer. Follow the step-by-step guide to ensure MySQL Server and its tools are installed and configured correctly for development or ...