The xMySql module contains the xMySqlServer, xMySqlDatabase, xMySqlUser, xMySqlGrant, xMySqlProvision DSC resources allowing you to setup and configure a MySQL servers, databases, users, and grants.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.
Please check out common DSC Resources contributing guidelines.
- xMySqlServer configures MySQL servers
- xMySqlDatabase configures MySQL databases.
- xMySqlUser configures MySQL users.
- xMySqlGrant configures MySQL grants.
- xMySqlProvison is a composite resource that provisions a set of MySQL servers, databases, users, and permission grants using the other resources.
- ServiceName: Provides the service name to use during setup of MySQL.
- Ensure: Ensures that the server is Present or Absent.
- RootPassword: The root password that is used to install a MySQL server. Note: a PSCredential object is used to store the password securely. The user name can be any non-zero length string, but it will be ignored.
- Name: Name of the database to create.
- Ensure: Ensures that the database is Present or Absent.
- ConnectionCredential: The credential that is used to create the MySQL database.
- Name: Name of the MySQL user to create or remove.
- Ensure: Ensures that the user is Present or Absent.
- Credential: Credential for the MySQL user.
- ConnectionCredential: The credential that is used to create or remove the user.
- UserName: Name of MySQL user.
- DatabaseName: MySQL database name to grant permissions.
- Ensure: Ensure permission grant is Present or Absent
- PermissionType: MySQL user permission type.
- ConnectionCredential: The credential that is used to create the grant.
- ServiceName: Provides the service name to use during setup of MySQL.
- DownloadUri: The URL/URI used for downloading the MySQL MSI.
- RootCredential:The MySQL root credentials, user name and password.
- DatabaseName: The MySQL database name.
- UserCredential:The credentials, user name and password, for the MySQL user.
- Changed to the default appveyor.yml template.
- Activate the GitHub App Stale on the GitHub repository.
- Added default template files .codecov.yml, .gitattributes, and .gitignore, and .vscode folder.
- Added new line to end of file for test files.
- Added import for local MSFT_xMySqlUtilities in Tests
- Fixed a SQL syntax error for REVOKE in MSFT_xMySqlGrant
- NOTE: This contains breaking Changes
- Updated all resources to contain unit tests
- Modified schema on many resources to standardize naming
- Fixed resources to removing hard coding of MySQL Version (Fixes #2)
- Removed Debug Tracing of Passwords (Fixes #3)
- Created standard library to reduce code redundancy
- Resolved attribute between *.psm1 and *.schema.mof files.
- Fixed encoding
- Initial release with the following resources :
- xMySqlServer
- xMySqlDatabase
- xMySqlUser
- xMySqlGrant
- xMySqlProvision
This configuration will setup a MySQL server on a single node.
Configuration SQLInstanceInstallationConfiguration
{
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String] $MySQLInstancePackagePath,
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String] $MySQLInstancePackageName
)
Import-DscResource -Module xMySql
node $AllNodes.NodeName
{
xPackage mySqlInstaller
{
Path = $MySQLInstancePackagePath
ProductId = $Node.PackageProductID
Name = $MySQLInstancePackageName
}
xMySqlServer MySQLInstance
{
Ensure = "Present"
RootPassword = $global:cred
ServiceName = "MySQLServerInstanceName"
DependsOn = "[xPackage]mySqlInstaller"
}
}
}
# Sample use (parameter values need to be changed according to your scenario):
$global:pwd = ConvertTo-SecureString "pass@word1" -AsPlainText -Force
$global:usrName = "administrator"
$global:cred = New-Object -TypeName System.Management.Automation.PSCredential ($global:usrName,$global:pwd)
SQLInstanceInstallationConfiguration `
-MySQLInstancePackagePath "http://dev.mysql.com/get/Downloads/MySQLInstaller/mysql-installer-community-5.6.17.0.msi" `
-MySQLInstancePackageName "MySQL Installer" -ConfigurationData .\nodedata.psd1
This configuration will setup a MySQL server and create a database.
Configuration SQLInstanceAndDatabaseInstallationConfiguration
{
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String] $MySQLInstancePackagePath,
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String] $MySQLInstancePackageName
)
Import-DscResource -Module xMySql
node $AllNodes.NodeName
{
xPackage mySqlInstaller
{
Path = $MySQLInstancePackagePath
ProductId = $Node.PackageProductID
Name = $MySQLInstancePackageName
Ensure = "Present"
}
xMySqlServer MySQLInstance
{
Ensure = "Present"
RootPassword= $global:cred
ServiceName = "MySQLInstanceServiceName"
DependsOn = "[xPackage]mySqlInstaller"
}
xMySqlDatabase MySQLDatabase
{
Ensure = "Present"
Name = "TestDB"
ConnectionCredential = $global:cred
DependsOn = "[xMySqlInstance]MySQLInstance"
}
}
}
# Sample use (parameter values need to be changed according to your scenario):
$global:pwd = ConvertTo-SecureString "pass@word1" -AsPlainText -Force
$global:usrName = "administrator"
$global:cred = New-Object -TypeName System.Management.Automation.PSCredential ($global:usrName,$global:pwd)
SQLInstanceAndDatabaseInstallationConfiguration `
-MySQLInstancePackagePath "http://dev.mysql.com/get/Downloads/MySQLInstaller/mysql-installer-community-5.6.17.0.msi" `
-MySQLInstancePackageName "MySQL Installer" -ConfigurationData .\nodedata.psd1
This configuration will setup a MySQL user, assuming mySQL is installed on a local machine with root user $RootUser and root password $global:pwd.
Configuration CreateMySQLUserConfiguration
{
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String] $Name
)
Import-DscResource -Module xMySql
$mySQLUserCredential = New-Object -TypeName System.Management.Automation.PSCredential ($Name,$global:pwd)
node ("localhost")
{
xMySqlUser NewMySqlUser1
{
Name = $Name
Credential = $mySQLUserCredential
Ensure = "Present"
ConnectionCredential = $global:MySQLRootCredential
}
}
}
$global:pwd = ConvertTo-SecureString "pass@word1" -AsPlainText -Force
$global:RootUser = "root"
$global:MySQLRootCredential = New-Object -TypeName System.Management.Automation.PSCredential ($global:RootUser,$global:pwd)
# Create localhost.mof
CreateMySQLUserConfiguration -output "$env:temp\CreateMySQLUserConfiguration"
This configuration will grant full acesss to a given MySQL database for a given user. It assumes that mySQL is installed on a local machine with root user $RootUser and root password $global:pwd.
configuration MySQLGrantConfiguration
{
param
(
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String] $UserName,
[parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String] $DatabaseName
)
Import-DscResource -Module xMySql
node ("localhost")
{
xMySqlGrant mySQLGrant
{
UserName = $UserName
DatabaseName = $DatabaseName
PermissionType = "ALL PRIVILEGES"
Ensure = "Present"
ConnectionCredential = $global:MySQLRootCredential
}
}
}
$global:pwd = ConvertTo-SecureString "pass@word1" -AsPlainText -Force
$global:RootUser = "root"
$global:MySQLRootCredential = New-Object -TypeName System.Management.Automation.PSCredential ($global:RootUser,$global:pwd)
# Create localhost.mof
CreateMySQLUserConfiguration -output "$env:temp\MySQLGrantConfiguration"