-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathStart-Mysql.ps1
More file actions
29 lines (23 loc) · 997 Bytes
/
Start-Mysql.ps1
File metadata and controls
29 lines (23 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function Start-Mysql {
param ()
# https://www.nuget.org/packages/MySqlConnector/1.3.10 lib/netstandard2.0/MySqlConnector.dll
$sqlConnectordll = Join-Path $PSScriptRoot 'MySqlConnector.dll'
Add-Type -Path $sqlConnectordll
$container = Start-Container -Image sqldatabase/mysql:9.4 -ContainerPort 3306
$builder = New-Object -TypeName MySqlConnector.MySqlConnectionStringBuilder
$builder['Database'] = 'sqldatabasetest'
$builder['User ID'] = 'root'
$builder['Password'] = 'qwerty'
$builder['ConnectionTimeout'] = 5
$builder.Server = 'localhost'
$builder.Port = $container.port.ToString()
$connectionString = $builder.ToString()
$builder.Server = $container.ip.ToString()
$builder.Port = 3306
$remoteConnectionString = $builder.ToString()
return @{
containerId = $container.containerId
connectionString = $connectionString
remoteConnectionString = $remoteConnectionString
}
}